file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
BlockClay.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockClay.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemClay; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockClay extends BlockSolid { public BlockClay() { } @Override public double getHardness() { return 0.6; } @Override public double getResistance() { return 3; } @Override public int getToolType() { return ItemTool.TYPE_SHOVEL; } @Override public int getId() { return CLAY_BLOCK; } @Override public String getName() { return "Clay Block"; } @Override public Item[] getDrops(Item item) { return new Item[]{ new ItemClay(0, 4) }; } @Override public BlockColor getColor() { return BlockColor.CLAY_BLOCK_COLOR; } }
897
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSignPost.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSignPost.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntitySign; import cn.nukkit.item.Item; import cn.nukkit.item.ItemSign; import cn.nukkit.item.ItemTool; import cn.nukkit.level.Level; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.Tag; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockSignPost extends BlockTransparentMeta { public BlockSignPost() { this(0); } public BlockSignPost(int meta) { super(meta); } @Override public int getId() { return SIGN_POST; } @Override public double getHardness() { return 1; } @Override public double getResistance() { return 5; } @Override public boolean isSolid() { return false; } @Override public String getName() { return "Sign Post"; } @Override public AxisAlignedBB getBoundingBox() { return null; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (face != BlockFace.DOWN) { CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.SIGN) .putInt("x", (int) block.x) .putInt("y", (int) block.y) .putInt("z", (int) block.z) .putString("Text1", "") .putString("Text2", "") .putString("Text3", "") .putString("Text4", ""); if (face == BlockFace.UP) { setDamage((int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f); getLevel().setBlock(block, new BlockSignPost(getDamage()), true); } else { setDamage(face.getIndex()); getLevel().setBlock(block, new BlockWallSign(getDamage()), true); } if (player != null) { nbt.putString("Creator", player.getUniqueId().toString()); } if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } new BlockEntitySign(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt); return true; } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (down().getId() == Block.AIR) { getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } return 0; } @Override public Item toItem() { return new ItemSign(); } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public BlockColor getColor() { return BlockColor.AIR_BLOCK_COLOR; } }
3,140
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockRailActivator.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockRailActivator.java
package cn.nukkit.block; import cn.nukkit.level.Level; import cn.nukkit.math.Vector3; import cn.nukkit.utils.Rail; /** * @author Nukkit Project Team */ public class BlockRailActivator extends BlockRail { public BlockRailActivator(int meta) { super(meta); } public BlockRailActivator() { this(0); canBePowered = true; } @Override public String getName() { return "Activator Rail"; } @Override public int getId() { return ACTIVATOR_RAIL; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE || type == Level.BLOCK_UPDATE_SCHEDULED) { super.onUpdate(type); boolean wasPowered = isActive(); boolean isPowered = level.isBlockPowered(this) || checkSurrounding(this, true, 0) || checkSurrounding(this, false, 0); boolean hasUpdate = false; if (wasPowered != isPowered) { setActive(isPowered); hasUpdate = true; } if (hasUpdate) { level.updateAround(down()); if (getOrientation().isAscending()) { level.updateAround(up()); } } return type; } return 0; } /** * Check the surrounding of the rail * * @param pos The rail position * @param relative The relative of the rail that will be checked * @param power The count of the rail that had been counted * @return Boolean of the surrounding area. Where the powered rail on! */ protected boolean checkSurrounding(Vector3 pos, boolean relative, int power) { if (power >= 8) { return false; } int dx = pos.getFloorX(); int dy = pos.getFloorY(); int dz = pos.getFloorZ(); BlockRail block; Block block2 = level.getBlock(new Vector3(dx, dy, dz)); if (Rail.isRailBlock(block2)) { block = (BlockRail) block2; } else { return false; } Rail.Orientation base = null; boolean onStraight = true; switch (block.getOrientation()) { case STRAIGHT_NORTH_SOUTH: if (relative) { dz++; } else { dz--; } break; case STRAIGHT_EAST_WEST: if (relative) { dx--; } else { dx++; } break; case ASCENDING_EAST: if (relative) { dx--; } else { dx++; dy++; onStraight = false; } base = Rail.Orientation.STRAIGHT_EAST_WEST; break; case ASCENDING_WEST: if (relative) { dx--; dy++; onStraight = false; } else { dx++; } base = Rail.Orientation.STRAIGHT_EAST_WEST; break; case ASCENDING_NORTH: if (relative) { dz++; } else { dz--; dy++; onStraight = false; } base = Rail.Orientation.STRAIGHT_NORTH_SOUTH; break; case ASCENDING_SOUTH: if (relative) { dz++; dy++; onStraight = false; } else { dz--; } base = Rail.Orientation.STRAIGHT_NORTH_SOUTH; break; default: return false; } return canPowered(new Vector3(dx, dy, dz), base, power, relative) || onStraight && canPowered(new Vector3(dx, dy - 1, dz), base, power, relative); } protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) { Block block = level.getBlock(pos); if (!(block instanceof BlockRailActivator)) { return false; } Rail.Orientation base = ((BlockRailActivator) block).getOrientation(); return (state != Rail.Orientation.STRAIGHT_EAST_WEST || base != Rail.Orientation.STRAIGHT_NORTH_SOUTH && base != Rail.Orientation.ASCENDING_NORTH && base != Rail.Orientation.ASCENDING_SOUTH) && (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH || base != Rail.Orientation.STRAIGHT_EAST_WEST && base != Rail.Orientation.ASCENDING_EAST && base != Rail.Orientation.ASCENDING_WEST) && (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1)); } }
5,067
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedLime.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLime.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedLime extends BlockTerracottaGlazed { public BlockTerracottaGlazedLime() { this(0); } public BlockTerracottaGlazedLime(int meta) { super(meta); } @Override public int getId() { return LIME_GLAZED_TERRACOTTA; } @Override public String getName() { return "Lime Glazed Terracotta"; } }
465
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockNetherBrick.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockNetherBrick.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/7 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockNetherBrick extends BlockSolid { public BlockNetherBrick() { } @Override public String getName() { return "Nether Bricks"; } @Override public int getId() { return NETHER_BRICKS; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 10; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.NETHERRACK_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
1,161
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockLiquid.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockLiquid.java
package cn.nukkit.block; import cn.nukkit.entity.Entity; import cn.nukkit.event.block.BlockFromToEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.level.particle.SmokeParticle; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.math.Vector3; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockLiquid extends BlockTransparentMeta { public int adjacentSources = 0; public final boolean[] isOptimalFlowDirection = {false, false, false, false}; public final int[] flowinCost = {0, 0, 0, 0}; private Vector3 temporalVector = null; protected BlockLiquid(int meta) { super(meta); } @Override public boolean hasEntityCollision() { return true; } @Override public boolean isBreakable(Item item) { return false; } @Override public boolean canBeReplaced() { return true; } @Override public boolean isSolid() { return false; } @Override public boolean canHarvestWithHand() { return false; } @Override public AxisAlignedBB getBoundingBox() { return null; } @Override public double getMaxY() { return this.y + 1 - getFluidHeightPercent(); } @Override protected AxisAlignedBB recalculateCollisionBoundingBox() { return this; } public float getFluidHeightPercent() { float d = (float) this.getDamage(); if (d >= 8) { d = 0; } return (d + 1) / 9f; } protected int getFlowDecay(Vector3 pos) { if (!(pos instanceof Block)) { pos = this.getLevel().getBlock(pos); } if (((Block) pos).getId() != this.getId()) { return -1; } else { return ((Block) pos).getDamage(); } } protected int getEffectiveFlowDecay(Vector3 pos) { if (!(pos instanceof Block)) { pos = this.getLevel().getBlock(pos); } if (((Block) pos).getId() != this.getId()) { return -1; } int decay = ((Block) pos).getDamage(); if (decay >= 8) { decay = 0; } return decay; } public Vector3 getFlowVector() { Vector3 vector = new Vector3(0, 0, 0); if (this.temporalVector == null) { this.temporalVector = new Vector3(0, 0, 0); } int decay = this.getEffectiveFlowDecay(this); for (int j = 0; j < 4; ++j) { double x = this.x; double y = this.y; double z = this.z; if (j == 0) { --x; } else if (j == 1) { ++x; } else if (j == 2) { --z; } else if (j == 3) { ++z; } Block sideBlock = this.getLevel().getBlock(this.temporalVector.setComponents(x, y, z)); int blockDecay = this.getEffectiveFlowDecay(sideBlock); if (blockDecay < 0) { if (!sideBlock.canBeFlowedInto()) { continue; } blockDecay = this.getEffectiveFlowDecay(this.getLevel().getBlock(this.temporalVector.setComponents(x, y - 1, z))); if (blockDecay >= 0) { int realDecay = blockDecay - (decay - 8); vector.x += (sideBlock.x - this.x) * realDecay; vector.y += (sideBlock.y - this.y) * realDecay; vector.z += (sideBlock.z - this.z) * realDecay; } continue; } else { int realDecay = blockDecay - decay; vector.x += (sideBlock.x - this.x) * realDecay; vector.y += (sideBlock.y - this.y) * realDecay; vector.z += (sideBlock.z - this.z) * realDecay; } } if (this.getDamage() >= 8) { boolean falling = false; if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x, this.y, this.z - 1)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x, this.y, this.z + 1)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x - 1, this.y, this.z)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x + 1, this.y, this.z)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x, this.y + 1, this.z - 1)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x, this.y + 1, this.z + 1)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x - 1, this.y + 1, this.z)).canBeFlowedInto()) { falling = true; } else if (!this.getLevel().getBlock(this.temporalVector.setComponents(this.x + 1, this.y + 1, this.z)).canBeFlowedInto()) { falling = true; } if (falling) { vector = vector.normalize().add(0, -6, 0); } } return vector.normalize(); } @Override public void addVelocityToEntity(Entity entity, Vector3 vector) { Vector3 flow = this.getFlowVector(); vector.x += flow.x; vector.y += flow.y; vector.z += flow.z; } @Override public int tickRate() { if (this instanceof BlockWater) { return 5; } else if (this instanceof BlockLava) { if (this.getLevel().getDimension() == Level.DIMENSION_NETHER) { return 5; } return 30; } return 0; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { this.checkForHarden(); this.getLevel().scheduleUpdate(this, this.tickRate()); } else if (type == Level.BLOCK_UPDATE_SCHEDULED) { if (this.temporalVector == null) { this.temporalVector = new Vector3(0, 0, 0); } int decay = this.getFlowDecay(this); int multiplier = this instanceof BlockLava ? 2 : 1; boolean flag = true; int smallestFlowDecay; if (decay > 0) { smallestFlowDecay = -100; this.adjacentSources = 0; smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y, this.z - 1)), smallestFlowDecay); smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y, this.z + 1)), smallestFlowDecay); smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock(this.temporalVector.setComponents(this.x - 1, this.y, this.z)), smallestFlowDecay); smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock(this.temporalVector.setComponents(this.x + 1, this.y, this.z)), smallestFlowDecay); int k = smallestFlowDecay + multiplier; if (k >= 8 || smallestFlowDecay < 0) { k = -1; } int topFlowDecay; if ((topFlowDecay = this.getFlowDecay(this.level.getBlock(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y + 1, this.z))))) >= 0) { if (topFlowDecay >= 8) { k = topFlowDecay; } else { k = topFlowDecay | 0x08; } } if (this.adjacentSources >= 2 && this instanceof BlockWater) { Block bottomBlock = this.level.getBlock(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y - 1, this.z))); if (bottomBlock.isSolid()) { k = 0; } else if (bottomBlock instanceof BlockWater && bottomBlock.getDamage() == 0) { k = 0; } } if (this instanceof BlockLava && decay < 8 && k < 8 && k > 1 && new Random().nextInt(4) != 0) { k = decay; flag = false; } if (k != decay) { decay = k; if (decay < 0) { this.getLevel().setBlock(this, new BlockAir(), true); } else { this.getLevel().setBlock(this, this.getBlock(decay), true); } } else if (flag) { //this.getLevel().scheduleUpdate(this, this.tickRate()); //this.updateFlow(); } } else { //this.updateFlow(); } Block bottomBlock = this.level.getBlock(this.temporalVector.setComponents(this.x, this.y - 1, this.z)); if (bottomBlock.canBeFlowedInto() || bottomBlock instanceof BlockLiquid) { if (this instanceof BlockLava && bottomBlock instanceof BlockWater) { Block to = new BlockStone(); to.setComponents(bottomBlock.getX(), bottomBlock.getY(), bottomBlock.getZ()); to.setLevel(bottomBlock.getLevel()); BlockFromToEvent ev = new BlockFromToEvent(bottomBlock, to); this.getLevel().getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(bottomBlock, ev.getTo(), true); this.triggerLavaMixEffects(bottomBlock); return 0; } } if (decay >= 8) { this.flowIntoBlock(bottomBlock, decay); } else { this.flowIntoBlock(bottomBlock, decay | 0x08); } } if (decay >= 0 && ((decay == 0 && this.getDamage() == 0) || (!bottomBlock.canBeFlowedInto() && !(bottomBlock instanceof BlockLiquid)))) { boolean[] flags = this.getOptimalFlowDirections(); int l = decay + multiplier; if (decay >= 8) { l = 1; } if (l >= 8) { this.checkForHarden(); return 0; } if (flags[0]) { this.flowIntoBlock(this.level.getBlock(this.temporalVector.setComponents(this.x - 1, this.y, this.z)), l); } if (flags[1]) { this.flowIntoBlock(this.level.getBlock(this.temporalVector.setComponents(this.x + 1, this.y, this.z)), l); } if (flags[2]) { this.flowIntoBlock(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y, this.z - 1)), l); } if (flags[3]) { this.flowIntoBlock(this.level.getBlock(this.temporalVector.setComponents(this.x, this.y, this.z + 1)), l); } } this.checkForHarden(); } return 0; } private void flowIntoBlock(Block block, int newFlowDecay) { if (block.canBeFlowedInto()) { if (block.getId() > 0) { if (this instanceof BlockLava) { this.triggerLavaMixEffects(block); } this.getLevel().useBreakOn(block); } this.getLevel().setBlock(block, this.getBlock(newFlowDecay), true); } } private int calculateFlowCost(Block block, int accumulatedCost, int previousDirection) { int cost = 1000; for (int j = 0; j < 4; ++j) { if ( (j == 0 && previousDirection == 1) || (j == 1 && previousDirection == 0) || (j == 2 && previousDirection == 3) || (j == 3 && previousDirection == 2) ) { double x = block.x; double y = block.y; double z = block.z; if (j == 0) { --x; } else if (j == 1) { ++x; } else if (j == 2) { --z; } else if (j == 3) { ++z; } Block blockSide = this.getLevel().getBlock(this.temporalVector.setComponents(x, y, z)); if (!blockSide.canBeFlowedInto() && !(blockSide instanceof BlockLiquid)) { continue; } else if (blockSide instanceof BlockLiquid && blockSide.getDamage() == 0) { continue; } else if (this.getLevel().getBlock(this.temporalVector.setComponents(x, y - 1, z)).canBeFlowedInto()) { return accumulatedCost; } if (accumulatedCost >= 4) { continue; } int realCost = this.calculateFlowCost(blockSide, accumulatedCost + 1, j); if (realCost < cost) { cost = realCost; } } } return cost; } @Override public double getHardness() { return 100; } @Override public double getResistance() { return 500; } private boolean[] getOptimalFlowDirections() { if (this.temporalVector == null) { this.temporalVector = new Vector3(0, 0, 0); } for (int j = 0; j < 4; ++j) { this.flowinCost[j] = 1000; double x = this.x; double y = this.y; double z = this.z; if (j == 0) { --x; } else if (j == 1) { ++x; } else if (j == 2) { --z; } else if (j == 3) { ++z; } Block block = this.getLevel().getBlock(this.temporalVector.setComponents(x, y, z)); if (!block.canBeFlowedInto() && !(block instanceof BlockLiquid)) { continue; } else if (block instanceof BlockLiquid && block.getDamage() == 0) { continue; } else if (this.getLevel().getBlock(this.temporalVector.setComponents(x, y - 1, z)).canBeFlowedInto()) { this.flowinCost[j] = 0; } else { this.flowinCost[j] = this.calculateFlowCost(block, 1, j); } } int minCost = this.flowinCost[0]; for (int i = 1; i < 4; ++i) { if (this.flowinCost[i] < minCost) { minCost = this.flowinCost[i]; } } for (int i = 0; i < 4; ++i) { this.isOptimalFlowDirection[i] = (this.flowinCost[i] == minCost); } return this.isOptimalFlowDirection; } private int getSmallestFlowDecay(Vector3 pos, int decay) { int blockDecay = this.getFlowDecay(pos); if (blockDecay < 0) { return decay; } else if (blockDecay == 0) { ++this.adjacentSources; } else if (blockDecay >= 8) { blockDecay = 0; } return (decay >= 0 && blockDecay >= decay) ? decay : blockDecay; } private void checkForHarden() { if (this instanceof BlockLava) { boolean colliding = false; for (BlockFace face : BlockFace.values()) { if (colliding = this.getSide(face) instanceof BlockWater) { break; } } if (colliding) { Block to; if (this.getDamage() == 0) { to = new BlockObsidian(); } else if (this.getDamage() <= 4) { to = new BlockCobblestone(); } else { return; } to.setComponents(this.getX(), this.getY(), this.getZ()); to.setLevel(this.getLevel()); BlockFromToEvent ev = new BlockFromToEvent(this, to); this.getLevel().getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getTo(), true); this.triggerLavaMixEffects(this); } } } } /** * Creates fizzing sound and smoke. Used when lava flows over block or mixes with water. */ protected void triggerLavaMixEffects(Vector3 pos) { this.getLevel().addSound(pos.add(0.5, 0.5, 0.5), Sound.RANDOM_FIZZ, 1, 2.6F + (ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.8F); for (int i = 0; i < 8; ++i) { this.getLevel().addParticle(new SmokeParticle(pos.add(Math.random(), 1.2, Math.random()))); } } public abstract BlockLiquid getBlock(int meta); @Override public boolean canPassThrough() { return true; } @Override public void onEntityCollide(Entity entity) { entity.resetFallDistance(); } }
17,749
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockFlowerPot.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockFlowerPot.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityFlowerPot; import cn.nukkit.item.Item; import cn.nukkit.item.ItemFlowerPot; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.Tag; /** * @author Nukkit Project Team */ public class BlockFlowerPot extends BlockFlowable { public BlockFlowerPot() { this(0); } public BlockFlowerPot(int meta) { super(meta); } protected static boolean canPlaceIntoFlowerPot(int id) { switch (id) { case SAPLING: case COBWEB: case TALL_GRASS: case DEAD_BUSH: case DANDELION: case ROSE: case RED_MUSHROOM: case BROWN_MUSHROOM: case CACTUS: case SUGARCANE_BLOCK: // TODO: 2016/2/4 case NETHER_WART: return true; default: return false; } } @Override public String getName() { return "Flower Pot"; } @Override public int getId() { return FLOWER_POT_BLOCK; } @Override public double getHardness() { return 0; } @Override public double getResistance() { return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (face != BlockFace.UP) return false; CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.FLOWER_POT) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z) .putShort("item", 0) .putInt("data", 0); if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } new BlockEntityFlowerPot(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt); this.getLevel().setBlock(block, this, true, true); return true; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item) { return this.onActivate(item, null); } @Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = getLevel().getBlockEntity(this); if (!(blockEntity instanceof BlockEntityFlowerPot)) return false; if (blockEntity.namedTag.getShort("item") != 0 || blockEntity.namedTag.getInt("mData") != 0) return false; int itemID; int itemMeta; if (!canPlaceIntoFlowerPot(item.getId())) { if (!canPlaceIntoFlowerPot(item.getBlock().getId())) { return true; } itemID = item.getBlock().getId(); itemMeta = item.getDamage(); } else { itemID = item.getId(); itemMeta = item.getDamage(); } blockEntity.namedTag.putShort("item", itemID); blockEntity.namedTag.putInt("data", itemMeta); this.setDamage(1); this.getLevel().setBlock(this, this, true); ((BlockEntityFlowerPot) blockEntity).spawnToAll(); if (player.isSurvival()) { item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item.getCount() > 0 ? item : Item.get(Item.AIR)); } return true; } @Override public Item[] getDrops(Item item) { boolean dropInside = false; int insideID = 0; int insideMeta = 0; BlockEntity blockEntity = getLevel().getBlockEntity(this); if (blockEntity instanceof BlockEntityFlowerPot) { dropInside = true; insideID = blockEntity.namedTag.getShort("item"); insideMeta = blockEntity.namedTag.getInt("data"); } if (dropInside) { return new Item[]{ new ItemFlowerPot(), Item.get(insideID, insideMeta, 1) }; } else { return new Item[]{ new ItemFlowerPot() }; } } @Override protected AxisAlignedBB recalculateBoundingBox() { return this; } @Override public double getMinX() { return this.x + 0.3125; } @Override public double getMinZ() { return this.z + 0.3125; } @Override public double getMaxX() { return this.x + 0.6875; } @Override public double getMaxY() { return this.y + 0.375; } @Override public double getMaxZ() { return this.z + 0.6875; } @Override public boolean canPassThrough() { return false; } @Override public Item toItem() { return new ItemFlowerPot(); } }
5,024
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsAcacia.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsAcacia.java
package cn.nukkit.block; /** * author: MagicDroidX * Nukkit Project */ public class BlockStairsAcacia extends BlockStairsWood { public BlockStairsAcacia() { this(0); } public BlockStairsAcacia(int meta) { super(meta); } @Override public int getId() { return ACACIA_WOOD_STAIRS; } @Override public String getName() { return "Acacia Wood Stairs"; } }
430
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTransparent.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTransparent.java
package cn.nukkit.block; import cn.nukkit.utils.BlockColor; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockTransparent extends Block { @Override public boolean isTransparent() { return true; } @Override public BlockColor getColor() { return BlockColor.TRANSPARENT_BLOCK_COLOR; } }
355
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockIronBars.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockIronBars.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/6 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockIronBars extends BlockThin { public BlockIronBars() { } @Override public String getName() { return "Iron Bars"; } @Override public int getId() { return IRON_BARS; } @Override public double getHardness() { return 5; } @Override public double getResistance() { return 10; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.IRON_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
1,140
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockQuartz.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockQuartz.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * author: MagicDroidX * Nukkit Project */ public class BlockQuartz extends BlockSolidMeta { public static final int QUARTZ_NORMAL = 0; public static final int QUARTZ_CHISELED = 1; public static final int QUARTZ_PILLAR = 2; public static final int QUARTZ_PILLAR2 = 3; public BlockQuartz() { this(0); } public BlockQuartz(int meta) { super(meta); } @Override public int getId() { return QUARTZ_BLOCK; } @Override public double getHardness() { return 0.8; } @Override public double getResistance() { return 4; } @Override public String getName() { String[] names = new String[]{ "Quartz Block", "Chiseled Quartz Block", "Quartz Pillar", "Quartz Pillar" }; return names[this.getDamage() & 0x03]; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (this.getDamage() != QUARTZ_NORMAL) { short[] faces = new short[]{ 0, 0, 0b1000, 0b1000, 0b0100, 0b0100 }; this.setDamage(((this.getDamage() & 0x03) | faces[face.getIndex()])); } this.getLevel().setBlock(block, this, true, true); return true; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public Item toItem() { return new ItemBlock(new BlockQuartz(), this.getDamage() & 0x03, 1); } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public BlockColor getColor() { return BlockColor.QUARTZ_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
2,597
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTNT.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTNT.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.entity.Entity; import cn.nukkit.entity.item.EntityPrimedTNT; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.NukkitRandom; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.DoubleTag; import cn.nukkit.nbt.tag.FloatTag; import cn.nukkit.nbt.tag.ListTag; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/8 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockTNT extends BlockSolid { public BlockTNT() { } @Override public String getName() { return "TNT"; } @Override public int getId() { return TNT; } @Override public double getHardness() { return 0; } @Override public double getResistance() { return 0; } @Override public boolean canBeActivated() { return true; } @Override public int getBurnChance() { return 15; } @Override public int getBurnAbility() { return 100; } public void prime() { this.prime(80); } public void prime(int fuse) { this.getLevel().setBlock(this, new BlockAir(), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putShort("Fuse", fuse); Entity tnt = new EntityPrimedTNT( this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt ); tnt.spawnToAll(); this.level.addSound(this, Sound.RANDOM_FUSE); } @Override public int onUpdate(int type) { if ((type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) && this.level.isBlockPowered(this)) { this.prime(); } return 0; } @Override public boolean onActivate(Item item, Player player) { if (item.getId() == Item.FLINT_STEEL) { item.useOn(this); this.prime(); return true; } return false; } @Override public BlockColor getColor() { return BlockColor.TNT_BLOCK_COLOR; } }
2,898
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEndPortal.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEndPortal.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.utils.BlockColor; public class BlockEndPortal extends BlockFlowable { public BlockEndPortal() { this(0); } public BlockEndPortal(int meta) { super(0); } @Override public String getName() { return "End Portal Block"; } @Override public int getId() { return END_PORTAL; } @Override public boolean canPassThrough() { return true; } @Override public boolean isBreakable(Item item) { return false; } @Override public double getHardness() { return -1; } @Override public double getResistance() { return 18000000; } @Override public int getLightLevel() { return 15; } @Override public boolean hasEntityCollision() { return true; } @Override public BlockColor getColor() { return BlockColor.AIR_BLOCK_COLOR; } @Override public boolean canBePushed() { return false; } @Override public boolean canHarvestWithHand() { return false; } }
1,162
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsCobblestone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsCobblestone.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsCobblestone extends BlockStairs { public BlockStairsCobblestone() { this(0); } public BlockStairsCobblestone(int meta) { super(meta); } @Override public int getId() { return COBBLESTONE_STAIRS; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Cobblestone Stairs"; } @Override public BlockColor getColor() { return BlockColor.STONE_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
973
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBeacon.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBeacon.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityBeacon; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; /** * author: Angelic47 Nukkit Project */ public class BlockBeacon extends BlockTransparent { public BlockBeacon() { } @Override public int getId() { return BEACON; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 15; } @Override public int getLightLevel() { return 15; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Beacon"; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { // TODO handle GUI //Server.getInstance().getLogger().info("BlockBeacon.onActivate called"); return true; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { boolean blockSuccess = super.place(item, block, target, face, fx, fy, fz, player); if (blockSuccess) { CompoundTag nbt = new CompoundTag("") .putString("id", BlockEntity.BEACON) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); new BlockEntityBeacon(this.level.getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); } return blockSuccess; } @Override public boolean canBePushed() { return false; } }
1,887
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBricksEndStone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBricksEndStone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; public class BlockBricksEndStone extends BlockSolid { public BlockBricksEndStone() { } @Override public String getName() { return "End Stone Bricks"; } @Override public int getId() { return END_BRICKS; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 0.8; } @Override public double getResistance() { return 4; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(Item.END_BRICKS, 0, 1) }; } else { return new Item[0]; } } }
876
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockHugeMushroomBrown.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockHugeMushroomBrown.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.item.ItemTool; import cn.nukkit.math.NukkitRandom; /** * Created by Pub4Game on 28.01.2016. */ public class BlockHugeMushroomBrown extends BlockSolidMeta { public BlockHugeMushroomBrown() { this(0); } public BlockHugeMushroomBrown(int meta) { super(meta); } @Override public String getName() { return "Brown Mushroom Block"; } @Override public int getId() { return BROWN_MUSHROOM_BLOCK; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public double getHardness() { return 0.2; } @Override public double getResistance() { return 1; } @Override public Item[] getDrops(Item item) { if (new NukkitRandom().nextRange(1, 20) == 0) { return new Item[]{ new ItemBlock(new BlockMushroomBrown()) }; } else { return new Item[0]; } } }
1,092
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoubleSlabRedSandstone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoubleSlabRedSandstone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; /** * Created by CreeperFace on 26. 11. 2016. */ public class BlockDoubleSlabRedSandstone extends BlockSolidMeta { public BlockDoubleSlabRedSandstone() { this(0); } public BlockDoubleSlabRedSandstone(int meta) { super(meta); } @Override public int getId() { return DOUBLE_RED_SANDSTONE_SLAB; } @Override public double getResistance() { return 30; } @Override public double getHardness() { return 2; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { String[] names = new String[]{ "Red Sandstone", "Purpur", "", "", "", "", "", "" }; return "Double " + names[this.getDamage() & 0x07] + " Slab"; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(Item.RED_SANDSTONE_SLAB, this.getDamage() & 0x07, 2) }; } else { return new Item[0]; } } @Override public boolean canHarvestWithHand() { return false; } }
1,434
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockCactus.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockCactus.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.entity.Entity; import cn.nukkit.event.block.BlockGrowEvent; import cn.nukkit.event.entity.EntityDamageByBlockEvent; import cn.nukkit.event.entity.EntityDamageEvent.DamageCause; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.math.SimpleAxisAlignedBB; import cn.nukkit.math.Vector3; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockCactus extends BlockTransparentMeta { public BlockCactus(int meta) { super(meta); } public BlockCactus() { this(0); } @Override public int getId() { return CACTUS; } @Override public double getHardness() { return 0.4; } @Override public double getResistance() { return 2; } @Override public boolean hasEntityCollision() { return true; } @Override public double getMinX() { return this.x + 0.0625; } @Override public double getMinY() { return this.y; } @Override public double getMinZ() { return this.z + 0.0625; } @Override public double getMaxX() { return this.x + 0.9375; } @Override public double getMaxY() { return this.y + 0.9375; } @Override public double getMaxZ() { return this.z + 0.9375; } @Override protected AxisAlignedBB recalculateCollisionBoundingBox() { return new SimpleAxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + 1); } @Override public void onEntityCollide(Entity entity) { entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.CONTACT, 1)); } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { Block down = down(); if (down.getId() != SAND && down.getId() != CACTUS) { this.getLevel().useBreakOn(this); } else { for (int side = 2; side <= 5; ++side) { Block block = getSide(BlockFace.fromIndex(side)); if (!block.canBeFlowedInto()) { this.getLevel().useBreakOn(this); } } } } else if (type == Level.BLOCK_UPDATE_RANDOM) { if (down().getId() != CACTUS) { if (this.getDamage() == 0x0F) { for (int y = 1; y < 3; ++y) { Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z)); if (b.getId() == AIR) { BlockGrowEvent event = new BlockGrowEvent(b, new BlockCactus()); Server.getInstance().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.getLevel().setBlock(b, event.getNewState(), true); } } } this.setDamage(0); this.getLevel().setBlock(this, this); } else { this.setDamage(this.getDamage() + 1); this.getLevel().setBlock(this, this); } } } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block down = this.down(); if (down.getId() == SAND || down.getId() == CACTUS) { Block block0 = north(); Block block1 = south(); Block block2 = west(); Block block3 = east(); if (block0.isTransparent() && block1.isTransparent() && block2.isTransparent() && block3.isTransparent()) { this.getLevel().setBlock(this, this, true); return true; } } return false; } @Override public String getName() { return "Cactus"; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
4,293
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTrapdoorIron.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTrapdoorIron.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created by Pub4Game on 26.12.2015. */ public class BlockTrapdoorIron extends BlockTrapdoor { public BlockTrapdoorIron() { this(0); } public BlockTrapdoorIron(int meta) { super(meta); } @Override public int getId() { return IRON_TRAPDOOR; } @Override public String getName() { return "Iron Trapdoor"; } @Override public double getHardness() { return 5; } @Override public double getResistance() { return 25; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public BlockColor getColor() { return BlockColor.IRON_BLOCK_COLOR; } @Override public boolean onActivate(Item item, Player player) { return false; } @Override public boolean canHarvestWithHand() { return false; } }
1,060
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsNetherBrick.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsNetherBrick.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsNetherBrick extends BlockStairs { public BlockStairsNetherBrick() { this(0); } public BlockStairsNetherBrick(int meta) { super(meta); } @Override public int getId() { return NETHER_BRICKS_STAIRS; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 10; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Nether Bricks Stairs"; } @Override public BlockColor getColor() { return BlockColor.NETHERRACK_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
982
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDiamond.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDiamond.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockDiamond extends BlockSolid { public BlockDiamond() { } @Override public double getHardness() { return 5; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public int getId() { return DIAMOND_BLOCK; } @Override public String getName() { return "Diamond Block"; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() > ItemTool.TIER_IRON) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.DIAMOND_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
1,097
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockJukebox.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockJukebox.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityJukebox; import cn.nukkit.item.Item; import cn.nukkit.item.ItemRecord; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.ListTag; /** * Created by CreeperFace on 7.8.2017. */ public class BlockJukebox extends BlockSolid { public BlockJukebox() { } @Override public String getName() { return "Jukebox"; } @Override public int getId() { return JUKEBOX; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = this.getLevel().getBlockEntity(this); if (blockEntity == null || !(blockEntity instanceof BlockEntityJukebox)) { blockEntity = this.createBlockEntity(); } BlockEntityJukebox jukebox = (BlockEntityJukebox) blockEntity; if (jukebox.getRecordItem().getId() != 0) { jukebox.dropItem(); } else if (item instanceof ItemRecord) { jukebox.setRecordItem(item); jukebox.play(); player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex()); } return false; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (super.place(item, block, target, face, fx, fy, fz, player)) { createBlockEntity(); return true; } return false; } @Override public boolean onBreak(Item item) { if (super.onBreak(item)) { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityJukebox) { ((BlockEntityJukebox) blockEntity).dropItem(); } return true; } return false; } private BlockEntity createBlockEntity() { CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.JUKEBOX) .putInt("x", getFloorX()) .putInt("y", getFloorY()) .putInt("z", getFloorZ()); return BlockEntity.createBlockEntity(BlockEntity.JUKEBOX, this.level.getChunk(getFloorX() >> 4, getFloorZ() >> 4), nbt); } }
2,498
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEndRod.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEndRod.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; /** * http://minecraft.gamepedia.com/End_Rod * * @author PikyCZ */ public class BlockEndRod extends BlockTransparentMeta { public BlockEndRod() { this(0); } public BlockEndRod(int meta) { super(meta); } @Override public String getName() { return "End Rod"; } @Override public int getId() { return END_ROD; } @Override public double getHardness() { return 0; } @Override public double getResistance() { return 0; } @Override public int getLightLevel() { return 14; } @Override public boolean canBePushed() { return true; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getMinX() { return this.x + 0.4; } @Override public double getMinZ() { return this.z + 0.4; } @Override public double getMaxX() { return this.x + 0.6; } @Override public double getMaxZ() { return this.z + 0.6; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { int[] faces = {0, 1, 3, 2, 5, 4}; this.setDamage(faces[player != null ? face.getIndex() : 0]); this.getLevel().setBlock(block, this, true, true); return true; } }
1,673
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockPistonSticky.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockPistonSticky.java
package cn.nukkit.block; /** * @author CreeperFace */ public class BlockPistonSticky extends BlockPistonBase { public BlockPistonSticky() { this(0); } public BlockPistonSticky(int meta) { super(meta); this.sticky = true; } @Override public int getId() { return STICKY_PISTON; } @Override public String getName() { return "Sticky Piston"; } }
429
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBookshelf.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBookshelf.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBook; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockBookshelf extends BlockSolidMeta { public BlockBookshelf(int meta) { super(meta); } public BlockBookshelf() { this(0); } @Override public String getName() { return "Bookshelf"; } @Override public int getId() { return BOOKSHELF; } @Override public double getHardness() { return 1.5D; } @Override public double getResistance() { return 7.5D; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public int getBurnChance() { return 30; } @Override public int getBurnAbility() { return 20; } @Override public Item[] getDrops(Item item) { return new Item[]{ new ItemBook(0, 3) }; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } }
1,141
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockFenceGateJungle.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockFenceGateJungle.java
package cn.nukkit.block; /** * Created on 2015/11/23 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockFenceGateJungle extends BlockFenceGate { public BlockFenceGateJungle() { this(0); } public BlockFenceGateJungle(int meta) { super(meta); } @Override public int getId() { return FENCE_GATE_JUNGLE; } @Override public String getName() { return "Jungle Fence Gate"; } }
475
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBedrockInvisible.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBedrockInvisible.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.utils.BlockColor; /** * Created by Pub4Game on 03.01.2016. */ public class BlockBedrockInvisible extends BlockSolid { public BlockBedrockInvisible() { } @Override public int getId() { return INVISIBLE_BEDROCK; } @Override public String getName() { return "Invisible Bedrock"; } @Override public double getHardness() { return -1; } @Override public double getResistance() { return 18000000; } @Override public boolean isBreakable(Item item) { return false; } @Override public BlockColor getColor() { return BlockColor.TRANSPARENT_BLOCK_COLOR; } @Override public boolean canBePushed() { return false; } }
833
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBricksNether.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBricksNether.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/7 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockBricksNether extends BlockSolid { public BlockBricksNether() { } @Override public String getName() { return "Nether Brick"; } @Override public int getId() { return NETHER_BRICKS; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 10; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(Item.NETHER_BRICKS, 0, 1) }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.NETHERRACK_BLOCK_COLOR; } }
1,103
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockFenceNetherBrick.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockFenceNetherBrick.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/7 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockFenceNetherBrick extends BlockFence { public BlockFenceNetherBrick() { this(0); } public BlockFenceNetherBrick(int meta) { super(meta); } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Nether Brick Fence"; } @Override public int getId() { return NETHER_BRICK_FENCE; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 10; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public boolean canConnect(Block block) { return (block instanceof BlockFenceNetherBrick || block instanceof BlockFenceGate) || block.isSolid() && !block.isTransparent(); } @Override public BlockColor getColor() { return BlockColor.NETHERRACK_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
1,475
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsSandstone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsSandstone.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsSandstone extends BlockStairs { public BlockStairsSandstone() { this(0); } public BlockStairsSandstone(int meta) { super(meta); } @Override public int getId() { return SANDSTONE_STAIRS; } @Override public double getHardness() { return 0.8; } @Override public double getResistance() { return 4; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Sandstone Stairs"; } @Override public BlockColor getColor() { return BlockColor.SAND_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
963
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockWool.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockWool.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; import cn.nukkit.utils.DyeColor; /** * Created on 2015/12/2 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockWool extends BlockSolidMeta { public BlockWool() { this(0); } public BlockWool(int meta) { super(meta); } public BlockWool(DyeColor dyeColor) { this(dyeColor.getWoolData()); } @Override public String getName() { return getDyeColor().getName() + " Wool"; } @Override public int getId() { return WOOL; } @Override public int getToolType() { return ItemTool.TYPE_SHEARS; } @Override public double getHardness() { return 0.8; } @Override public double getResistance() { return 4; } @Override public int getBurnChance() { return 30; } @Override public int getBurnAbility() { return 60; } @Override public BlockColor getColor() { return DyeColor.getByWoolData(getDamage()).getColor(); } public DyeColor getDyeColor() { return DyeColor.getByWoolData(getDamage()); } }
1,231
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoorBirch.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoorBirch.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemDoorBirch; public class BlockDoorBirch extends BlockDoorWood { public BlockDoorBirch() { this(0); } public BlockDoorBirch(int meta) { super(meta); } @Override public String getName() { return "Birch Door Block"; } @Override public int getId() { return BIRCH_DOOR_BLOCK; } @Override public Item toItem() { return new ItemDoorBirch(); } }
515
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedOrange.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedOrange.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedOrange extends BlockTerracottaGlazed { public BlockTerracottaGlazedOrange() { this(0); } public BlockTerracottaGlazedOrange(int meta) { super(meta); } @Override public int getId() { return ORANGE_GLAZED_TERRACOTTA; } @Override public String getName() { return "Orange Glazed Terracotta"; } }
475
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockButton.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockButton.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.event.block.BlockRedstoneEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; import cn.nukkit.math.Vector3; /** * Created by CreeperFace on 27. 11. 2016. */ public abstract class BlockButton extends BlockFlowable { public BlockButton() { this(0); } public BlockButton(int meta) { super(meta); } @Override public double getResistance() { return 2.5; } @Override public double getHardness() { return 0.5; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (target.isTransparent()) { return false; } this.setDamage(face.getIndex()); this.level.setBlock(block, this, true, true); return true; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { if (this.isActivated()) { return false; } this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15)); this.setDamage(this.getDamage() ^ 0x08); this.level.setBlock(this, this, true, false); this.level.addSound(this.add(0.5, 0.5, 0.5), Sound.RANDOM_CLICK); this.level.scheduleUpdate(this, 30); Vector3 pos = getLocation(); level.updateAroundRedstone(pos, null); level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null); return true; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.getSide(getFacing().getOpposite()).isTransparent()) { this.level.useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_SCHEDULED) { if (this.isActivated()) { this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0)); this.setDamage(this.getDamage() ^ 0x08); this.level.setBlock(this, this, true, false); this.level.addSound(this.add(0.5, 0.5, 0.5), Sound.RANDOM_CLICK); Vector3 pos = getLocation(); level.updateAroundRedstone(pos, null); level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null); } return Level.BLOCK_UPDATE_SCHEDULED; } return 0; } public boolean isActivated() { return ((this.getDamage() & 0x08) == 0x08); } @Override public boolean isPowerSource() { return true; } public int getWeakPower(BlockFace side) { return isActivated() ? 15 : 0; } public int getStrongPower(BlockFace side) { return !isActivated() ? 0 : (getFacing() == side ? 15 : 0); } public BlockFace getFacing() { int side = isActivated() ? getDamage() ^ 0x08 : getDamage(); return BlockFace.fromIndex(side); } @Override public boolean onBreak(Item item) { if (isActivated()) { this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0)); } return super.onBreak(item); } @Override public Item toItem() { return Item.get(this.getId(), 0, 1); } }
3,560
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedMagenta.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedMagenta.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedMagenta extends BlockTerracottaGlazed { public BlockTerracottaGlazedMagenta() { this(0); } public BlockTerracottaGlazedMagenta(int meta) { super(meta); } @Override public int getId() { return MAGENTA_GLAZED_TERRACOTTA; } @Override public String getName() { return "Magenta Glazed Terracotta"; } }
480
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockCraftingTable.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockCraftingTable.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.inventory.BigCraftingGrid; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/5 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockCraftingTable extends BlockSolid { public BlockCraftingTable() { } @Override public String getName() { return "Crafting Table"; } @Override public int getId() { return WORKBENCH; } @Override public boolean canBeActivated() { return true; } @Override public double getHardness() { return 2.5; } @Override public double getResistance() { return 15; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public boolean onActivate(Item item, Player player) { if (player != null) { player.setCraftingGrid(new BigCraftingGrid(player)); player.craftingType = Player.CRAFTING_BIG; } return true; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } }
1,208
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockGlassPaneStained.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockGlassPaneStained.java
package cn.nukkit.block; import cn.nukkit.utils.BlockColor; import cn.nukkit.utils.DyeColor; /** * Created by CreeperFace on 7.8.2017. */ public class BlockGlassPaneStained extends BlockGlassPane { private int meta; public BlockGlassPaneStained() { this(0); } public BlockGlassPaneStained(int meta) { this.meta = meta; } @Override public int getFullId() { return (getId() << 4) + getDamage(); } @Override public int getId() { return STAINED_GLASS_PANE; } @Override public String getName() { return getDyeColor().getName() + " stained glass pane"; } @Override public BlockColor getColor() { return getDyeColor().getColor(); } public DyeColor getDyeColor() { return DyeColor.getByWoolData(getDamage()); } @Override public final int getDamage() { return this.meta; } @Override public final void setDamage(int meta) { this.meta = meta; } }
1,022
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBricks.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBricks.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockBricks extends BlockSolid { public BlockBricks() { } @Override public String getName() { return "Bricks"; } @Override public int getId() { return BRICKS_BLOCK; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(Item.BRICKS_BLOCK, 0, 1) }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.STONE_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
1,113
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSlime.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSlime.java
package cn.nukkit.block; /** * Created by Pub4Game on 21.02.2016. */ public class BlockSlime extends BlockSolid { public BlockSlime() { } @Override public double getHardness() { return 0; } @Override public String getName() { return "Slime Block"; } @Override public int getId() { return SLIME_BLOCK; } @Override public double getResistance() { return 0; } }
455
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockConcretePowder.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockConcretePowder.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; /** * Created by CreeperFace on 2.6.2017. */ public class BlockConcretePowder extends BlockFallable { private int meta; public BlockConcretePowder() { this(0); } public BlockConcretePowder(int meta) { this.meta = meta; } @Override public int getFullId() { return (getId() << 4) + getDamage(); } @Override public final int getDamage() { return this.meta; } @Override public final void setDamage(int meta) { this.meta = meta; } @Override public int getId() { return CONCRETE_POWDER; } @Override public String getName() { return "Concrete Powder"; } @Override public double getResistance() { return 2.5; } @Override public double getHardness() { return 0.5; } @Override public int getToolType() { return ItemTool.TYPE_SHOVEL; } }
994
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockAnvil.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockAnvil.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.inventory.AnvilInventory; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * Created by Pub4Game on 27.12.2015. */ public class BlockAnvil extends BlockFallable { private int meta; public BlockAnvil() { this(0); } public BlockAnvil(int meta) { this.meta = meta; } @Override public int getFullId() { return (getId() << 4) + getDamage(); } @Override public final int getDamage() { return this.meta; } @Override public final void setDamage(int meta) { this.meta = meta; } @Override public int getId() { return ANVIL; } @Override public boolean canBeActivated() { return true; } @Override public boolean isTransparent() { return true; } @Override public double getHardness() { return 5; } @Override public double getResistance() { return 6000; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { String[] names = new String[]{ "Anvil", "Anvil", "Anvil", "Anvil", "Slighty Damaged Anvil", "Slighty Damaged Anvil", "Slighty Damaged Anvil", "Slighty Damaged Anvil", "Very Damaged Anvil", "Very Damaged Anvil", "Very Damaged Anvil", "Very Damaged Anvil" }; return names[this.getDamage()]; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (!target.isTransparent()) { int damage = this.getDamage(); int[] faces = {1, 2, 3, 0}; this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]); if (damage >= 4 && damage <= 7) { this.setDamage(this.getDamage() | 0x04); } else if (damage >= 8 && damage <= 11) { this.setDamage(this.getDamage() | 0x08); } this.getLevel().setBlock(block, this, true); this.getLevel().addSound(this, Sound.RANDOM_ANVIL_LAND, 1, 0.8F); return true; } return false; } @Override public boolean onActivate(Item item, Player player) { if (player != null) { player.addWindow(new AnvilInventory(this), Player.ANVIL_WINDOW_ID); } return true; } @Override public Item[] getDrops(Item item) { int damage = this.getDamage(); if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { Item drop = this.toItem(); if (damage >= 4 && damage <= 7) { //Slightly Anvil drop.setDamage(drop.getDamage() & 0x04); } else if (damage >= 8 && damage <= 11) { //Very Damaged Anvil drop.setDamage(drop.getDamage() & 0x08); } } return new Item[0]; } @Override public BlockColor getColor() { return BlockColor.IRON_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
3,496
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockRailPowered.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockRailPowered.java
package cn.nukkit.block; import cn.nukkit.level.Level; import cn.nukkit.math.Vector3; import cn.nukkit.utils.Rail; /** * Created by Snake1999 on 2016/1/11. * Contributed by: larryTheCoder on 2017/7/18. * <p> * Nukkit Project, * Minecart and Riding Project, * Package cn.nukkit.block in project Nukkit. */ public class BlockRailPowered extends BlockRail { public BlockRailPowered() { this(0); canBePowered = true; } public BlockRailPowered(int meta) { super(meta); } @Override public int getId() { return POWERED_RAIL; } @Override public String getName() { return "Powered Rail"; } @Override public int onUpdate(int type) { // Warning: I din't recommended this on slow networks server or slow client // Network below 86Kb/s. This will became unresponsive to clients // When updating the block state. Espicially on the world with many rails. // Trust me, I tested this on my server. if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE || type == Level.BLOCK_UPDATE_SCHEDULED) { super.onUpdate(type); boolean wasPowered = isActive(); boolean isPowered = level.isBlockPowered(this) || checkSurrounding(this, true, 0) || checkSurrounding(this, false, 0); // Avoid Block minstake if (wasPowered != isPowered) { setActive(isPowered); level.updateAround(down()); if (getOrientation().isAscending()) { level.updateAround(up()); } } return type; } return 0; } /** * Check the surrounding of the rail * * @param pos The rail position * @param relative The relative of the rail that will be checked * @param power The count of the rail that had been counted * @return Boolean of the surrounding area. Where the powered rail on! */ protected boolean checkSurrounding(Vector3 pos, boolean relative, int power) { // The powered rail can power up to 8 blocks only if (power >= 8) { return false; } // The position of the floor numbers int dx = pos.getFloorX(); int dy = pos.getFloorY(); int dz = pos.getFloorZ(); // First: get the base block BlockRail block; Block block2 = level.getBlock(new Vector3(dx, dy, dz)); // Second: check if the rail is Powered rail if (Rail.isRailBlock(block2)) { block = (BlockRail) block2; } else { return false; } // Used to check if the next ascending rail should be what Rail.Orientation base = null; boolean onStraight = true; // Third: Recalculate the base position switch (block.getOrientation()) { case STRAIGHT_NORTH_SOUTH: if (relative) { dz++; } else { dz--; } break; case STRAIGHT_EAST_WEST: if (relative) { dx--; } else { dx++; } break; case ASCENDING_EAST: if (relative) { dx--; } else { dx++; dy++; onStraight = false; } base = Rail.Orientation.STRAIGHT_EAST_WEST; break; case ASCENDING_WEST: if (relative) { dx--; dy++; onStraight = false; } else { dx++; } base = Rail.Orientation.STRAIGHT_EAST_WEST; break; case ASCENDING_NORTH: if (relative) { dz++; } else { dz--; dy++; onStraight = false; } base = Rail.Orientation.STRAIGHT_NORTH_SOUTH; break; case ASCENDING_SOUTH: if (relative) { dz++; dy++; onStraight = false; } else { dz--; } base = Rail.Orientation.STRAIGHT_NORTH_SOUTH; break; default: // Unable to determinate the rail orientation // Wrong rail? return false; } // Next check the if rail is on power state return canPowered(new Vector3(dx, dy, dz), base, power, relative) || onStraight && canPowered(new Vector3(dx, dy - 1, dz), base, power, relative); } protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) { Block block = level.getBlock(pos); // What! My block is air??!! Impossible! XD if (!(block instanceof BlockRailPowered)) { return false; } // Sometimes the rails are diffrent orientation Rail.Orientation base = ((BlockRailPowered) block).getOrientation(); // Possible way how to know when the rail is activated is rail were directly powered // OR recheck the surrounding... Which will returns here =w= return (state != Rail.Orientation.STRAIGHT_EAST_WEST || base != Rail.Orientation.STRAIGHT_NORTH_SOUTH && base != Rail.Orientation.ASCENDING_NORTH && base != Rail.Orientation.ASCENDING_SOUTH) && (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH || base != Rail.Orientation.STRAIGHT_EAST_WEST && base != Rail.Orientation.ASCENDING_EAST && base != Rail.Orientation.ASCENDING_WEST) && (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1)); } }
6,176
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockOreDiamond.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockOreDiamond.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemDiamond; import cn.nukkit.item.ItemTool; import cn.nukkit.item.enchantment.Enchantment; import cn.nukkit.math.NukkitRandom; import java.util.concurrent.ThreadLocalRandom; /** * author: MagicDroidX * Nukkit Project */ public class BlockOreDiamond extends BlockSolid { public BlockOreDiamond() { } @Override public int getId() { return DIAMOND_ORE; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 15; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Diamond Ore"; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) { int count = 1; Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING); if (fortune != null && fortune.getLevel() >= 1) { int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1; if (i < 0) { i = 0; } count = i + 1; } return new Item[]{ new ItemDiamond(0, count) }; } else { return new Item[0]; } } @Override public int getDropExp() { return new NukkitRandom().nextRange(3, 7); } @Override public boolean canHarvestWithHand() { return false; } }
1,645
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDispenser.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDispenser.java
package cn.nukkit.block; import cn.nukkit.math.BlockFace; import cn.nukkit.math.Vector3; /** * Created by CreeperFace on 15.4.2017. */ public class BlockDispenser extends BlockSolidMeta { public BlockDispenser() { this(0); } public BlockDispenser(int meta) { super(meta); } @Override public boolean hasComparatorInputOverride() { return true; } @Override public String getName() { return "Dispenser"; } @Override public int getId() { return DISPENSER; } @Override public int getComparatorInputOverride() { /*BlockEntity blockEntity = this.level.getBlockEntity(this); if(blockEntity instanceof BlockEntityDispenser) { //return ContainerInventory.calculateRedstone(((BlockEntityDispenser) blockEntity).getInventory()); TODO: dispenser }*/ return super.getComparatorInputOverride(); } public BlockFace getFacing() { return BlockFace.fromIndex(this.getDamage() & 7); } public boolean isTriggered() { return (this.getDamage() & 8) > 0; } public void setTriggered(boolean value) { int i = 0; i |= getFacing().getIndex(); if (value) { i |= 8; } this.setDamage(i); } @Override public boolean canHarvestWithHand() { return false; } public Vector3 getDispensePosition() { BlockFace facing = getFacing(); double x = this.getX() + 0.7 * facing.getXOffset(); double y = this.getY() + 0.7 * facing.getYOffset(); double z = this.getZ() + 0.7 * facing.getZOffset(); return new Vector3(x, y, z); } }
1,710
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTransparentMeta.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTransparentMeta.java
package cn.nukkit.block; import cn.nukkit.utils.BlockColor; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockTransparentMeta extends BlockMeta { protected BlockTransparentMeta() { this(0); } protected BlockTransparentMeta(int meta) { super(meta); } @Override public boolean isTransparent() { return true; } @Override public BlockColor getColor() { return BlockColor.TRANSPARENT_BLOCK_COLOR; } }
501
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockCobblestone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockCobblestone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; /** * author: Angelic47 * Nukkit Project */ public class BlockCobblestone extends BlockSolid { public BlockCobblestone() { } @Override public int getId() { return COBBLESTONE; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Cobblestone"; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public boolean canHarvestWithHand() { return false; } }
974
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockWaterStill.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockWaterStill.java
package cn.nukkit.block; /** * author: Angelic47 * Nukkit Project */ public class BlockWaterStill extends BlockWater { public BlockWaterStill() { super(0); } public BlockWaterStill(int meta) { super(meta); } @Override public int getId() { return STILL_WATER; } @Override public String getName() { return "Still Water"; } @Override public BlockLiquid getBlock(int meta) { return new BlockWaterStill(meta); } }
511
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSeaLantern.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSeaLantern.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemPrismarineCrystals; import cn.nukkit.utils.BlockColor; import java.util.concurrent.ThreadLocalRandom; public class BlockSeaLantern extends BlockTransparent { public BlockSeaLantern() { } @Override public String getName() { return "Sea Lantern"; } @Override public int getId() { return SEA_LANTERN; } @Override public double getResistance() { return 1.5; } @Override public double getHardness() { return 0.3; } @Override public int getLightLevel() { return 15; } @Override public Item[] getDrops(Item item) { return new Item[]{ new ItemPrismarineCrystals(0, ThreadLocalRandom.current().nextInt(2, 4)) }; } @Override public BlockColor getColor() { return BlockColor.AIR_BLOCK_COLOR; } }
947
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBrewingStand.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBrewingStand.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityBrewingStand; import cn.nukkit.inventory.ContainerInventory; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBrewingStand; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.ListTag; import cn.nukkit.nbt.tag.StringTag; import cn.nukkit.nbt.tag.Tag; import cn.nukkit.utils.BlockColor; import java.util.Map; public class BlockBrewingStand extends BlockSolidMeta { public BlockBrewingStand() { this(0); } public BlockBrewingStand(int meta) { super(meta); } @Override public String getName() { return "Brewing Stand"; } @Override public boolean canBeActivated() { return true; } @Override public double getHardness() { return 0.5; } @Override public double getResistance() { return 2.5; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public int getId() { return BREWING_STAND_BLOCK; } @Override public int getLightLevel() { return 1; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (!block.down().isTransparent()) { getLevel().setBlock(block, this, true, true); CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.BREWING_STAND) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); if (item.hasCustomName()) { nbt.putString("CustomName", item.getCustomName()); } if (item.hasCustomBlockData()) { Map<String, Tag> customData = item.getCustomBlockData().getTags(); for (Map.Entry<String, Tag> tag : customData.entrySet()) { nbt.put(tag.getKey(), tag.getValue()); } } new BlockEntityBrewingStand(getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); return true; } return false; } @Override public boolean onActivate(Item item, Player player) { if (player != null) { BlockEntity t = getLevel().getBlockEntity(this); BlockEntityBrewingStand brewing; if (t instanceof BlockEntityBrewingStand) { brewing = (BlockEntityBrewingStand) t; } else { CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.BREWING_STAND) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); brewing = new BlockEntityBrewingStand(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt); } if (brewing.namedTag.contains("Lock") && brewing.namedTag.get("Lock") instanceof StringTag) { if (!brewing.namedTag.getString("Lock").equals(item.getCustomName())) { return false; } } player.addWindow(brewing.getInventory()); } return true; } @Override public Item toItem() { return new ItemBrewingStand(); } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.IRON_BLOCK_COLOR; } public boolean hasComparatorInputOverride() { return true; } @Override public int getComparatorInputOverride() { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityBrewingStand) { return ContainerInventory.calculateRedstone(((BlockEntityBrewingStand) blockEntity).getInventory()); } return super.getComparatorInputOverride(); } @Override public boolean canHarvestWithHand() { return false; } }
4,569
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEnderChest.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEnderChest.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityEnderChest; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.StringTag; import cn.nukkit.nbt.tag.Tag; import cn.nukkit.utils.BlockColor; import java.util.HashSet; import java.util.Map; import java.util.Set; public class BlockEnderChest extends BlockTransparentMeta { private Set<Player> viewers = new HashSet<>(); public BlockEnderChest() { this(0); } public BlockEnderChest(int meta) { super(meta); } @Override public boolean canBeActivated() { return true; } @Override public int getId() { return ENDER_CHEST; } @Override public int getLightLevel() { return 7; } @Override public String getName() { return "Chest"; } @Override public double getHardness() { return 22.5; } @Override public double getResistance() { return 3000; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getMinX() { return this.x + 0.0625; } @Override public double getMinZ() { return this.z + 0.0625; } @Override public double getMaxX() { return this.x + 0.9375; } @Override public double getMaxY() { return this.y + 0.9475; } @Override public double getMaxZ() { return this.z + 0.9375; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { int[] faces = {2, 5, 3, 4}; this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]); this.getLevel().setBlock(block, this, true, true); CompoundTag nbt = new CompoundTag("") .putString("id", BlockEntity.ENDER_CHEST) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); if (item.hasCustomName()) { nbt.putString("CustomName", item.getCustomName()); } if (item.hasCustomBlockData()) { Map<String, Tag> customData = item.getCustomBlockData().getTags(); for (Map.Entry<String, Tag> tag : customData.entrySet()) { nbt.put(tag.getKey(), tag.getValue()); } } new BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); return true; } @Override public boolean onActivate(Item item, Player player) { if (player != null) { Block top = this.up(); if (!top.isTransparent()) { return true; } BlockEntity t = this.getLevel().getBlockEntity(this); BlockEntityEnderChest chest; if (t instanceof BlockEntityEnderChest) { chest = (BlockEntityEnderChest) t; } else { CompoundTag nbt = new CompoundTag("") .putString("id", BlockEntity.ENDER_CHEST) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); chest = new BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); } if (chest.namedTag.contains("Lock") && chest.namedTag.get("Lock") instanceof StringTag) { if (!chest.namedTag.getString("Lock").equals(item.getCustomName())) { return true; } } player.setViewingEnderChest(this); player.addWindow(player.getEnderChestInventory()); } return true; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(Item.OBSIDIAN, 0, 8) }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return BlockColor.OBSIDIAN_BLOCK_COLOR; } public Set<Player> getViewers() { return viewers; } @Override public boolean canBePushed() { return false; } @Override public boolean canHarvestWithHand() { return false; } }
4,619
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedBrown.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBrown.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedBrown extends BlockTerracottaGlazed { public BlockTerracottaGlazedBrown() { this(0); } public BlockTerracottaGlazedBrown(int meta) { super(meta); } @Override public int getId() { return BROWN_GLAZED_TERRACOTTA; } @Override public String getName() { return "Brown Glazed Terracotta"; } }
470
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEndStone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEndStone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; /** * Created on 2015/12/1 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockEndStone extends BlockSolid { public BlockEndStone() { } @Override public String getName() { return "End Stone"; } @Override public int getId() { return END_STONE; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 45; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public boolean canHarvestWithHand() { return false; } }
1,006
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsSpruce.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsSpruce.java
package cn.nukkit.block; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsSpruce extends BlockStairsWood { public BlockStairsSpruce() { this(0); } public BlockStairsSpruce(int meta) { super(meta); } @Override public int getId() { return SPRUCE_WOOD_STAIRS; } @Override public String getName() { return "Spruce Wood Stairs"; } }
471
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSkull.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSkull.java
package cn.nukkit.block; /** * author: Justin */ import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntitySkull; import cn.nukkit.item.Item; import cn.nukkit.item.ItemSkull; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.Tag; public class BlockSkull extends BlockTransparentMeta { public BlockSkull() { this(0); } public BlockSkull(int meta) { super(meta); } @Override public int getId() { return SKULL_BLOCK; } @Override public double getHardness() { return 1; } @Override public double getResistance() { return 5; } @Override public boolean isSolid() { return false; } @Override public String getName() { int itemMeta = 0; if (this.level != null) { BlockEntity blockEntity = getLevel().getBlockEntity(this); if (blockEntity != null) itemMeta = blockEntity.namedTag.getByte("SkullType"); } return ItemSkull.getItemSkullName(itemMeta); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { switch (face) { case NORTH: case SOUTH: case EAST: case WEST: case UP: this.setDamage(face.getIndex()); break; case DOWN: default: return false; } this.getLevel().setBlock(block, this, true, true); CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.SKULL) .putByte("SkullType", item.getDamage()) .putInt("x", block.getFloorX()) .putInt("y", block.getFloorY()) .putInt("z", block.getFloorZ()) .putByte("Rot", (int) Math.floor((player.yaw * 16 / 360) + 0.5) & 0x0f); if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } new BlockEntitySkull(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt); // TODO: 2016/2/3 SPAWN WITHER return true; } @Override public Item[] getDrops(Item item) { BlockEntity blockEntity = getLevel().getBlockEntity(this); int dropMeta = 0; if (blockEntity != null) dropMeta = blockEntity.namedTag.getByte("SkullType"); return new Item[]{ new ItemSkull(dropMeta) }; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } }
3,012
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockNetherWart.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockNetherWart.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.event.block.BlockGrowEvent; import cn.nukkit.item.Item; import cn.nukkit.item.ItemNetherWart; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; import java.util.Random; /** * Created by Leonidius20 on 22.03.17. */ public class BlockNetherWart extends BlockFlowable { public BlockNetherWart() { this(0); } public BlockNetherWart(int meta) { super(meta); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block down = this.down(); if (down.getId() == SOUL_SAND) { this.getLevel().setBlock(block, this, true, true); return true; } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().getId() != SOUL_SAND) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_RANDOM) { if (new Random().nextInt(10) == 1) { if (this.getDamage() < 0x03) { BlockNetherWart block = (BlockNetherWart) this.clone(); block.setDamage(block.getDamage() + 1); BlockGrowEvent ev = new BlockGrowEvent(this, block); Server.getInstance().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getNewState(), true, true); } else { return Level.BLOCK_UPDATE_RANDOM; } } } else { return Level.BLOCK_UPDATE_RANDOM; } } return 0; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } @Override public String getName() { return "Nether Wart Block"; } @Override public int getId() { return NETHER_WART_BLOCK; } @Override public Item[] getDrops(Item item) { if (this.getDamage() == 0x03) { return new Item[]{ new ItemNetherWart(0, 2 + (int) (Math.random() * ((4 - 2) + 1))) }; } else { return new Item[]{ new ItemNetherWart() }; } } @Override public Item toItem() { return new ItemNetherWart(); } }
2,872
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoorAcacia.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoorAcacia.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemDoorAcacia; public class BlockDoorAcacia extends BlockDoorWood { public BlockDoorAcacia() { this(0); } public BlockDoorAcacia(int meta) { super(meta); } @Override public String getName() { return "Acacia Door Block"; } @Override public int getId() { return ACACIA_DOOR_BLOCK; } @Override public Item toItem() { return new ItemDoorAcacia(); } }
522
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSugarcane.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSugarcane.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.event.block.BlockGrowEvent; import cn.nukkit.item.Item; import cn.nukkit.item.ItemSugarcane; import cn.nukkit.level.Level; import cn.nukkit.level.particle.BoneMealParticle; import cn.nukkit.math.BlockFace; import cn.nukkit.math.Vector3; import cn.nukkit.utils.BlockColor; /** * Created by Pub4Game on 09.01.2016. */ public class BlockSugarcane extends BlockFlowable { public BlockSugarcane() { this(0); } public BlockSugarcane(int meta) { super(meta); } @Override public String getName() { return "Sugarcane"; } @Override public int getId() { return SUGARCANE_BLOCK; } @Override public Item toItem() { return new ItemSugarcane(); } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal int count = 1; for (int i = 1; i <= 2; i++) { int id = this.level.getBlockIdAt(this.getFloorX(), this.getFloorY() - i, this.getFloorZ()); if (id == SUGARCANE_BLOCK) { count++; } } if (count < 3) { int toGrow = 3 - count; for (int i = 1; i <= toGrow; i++) { Block block = this.up(i); if (block.getId() == 0) { BlockGrowEvent ev = new BlockGrowEvent(block, new BlockSugarcane()); Server.getInstance().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(block, ev.getNewState(), true); } } else if (block.getId() != SUGARCANE_BLOCK) { break; } } } if ((player.gamemode & 0x01) == 0) { item.count--; } this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5))); return true; } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { Block down = this.down(); if (down.isTransparent() && down.getId() != SUGARCANE_BLOCK) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_RANDOM) { if (this.down().getId() != SUGARCANE_BLOCK) { if (this.getDamage() == 0x0F) { for (int y = 1; y < 3; ++y) { Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z)); if (b.getId() == AIR) { this.getLevel().setBlock(b, new BlockSugarcane(), false); break; } } this.setDamage(0); this.getLevel().setBlock(this, this, false); } else { this.setDamage(this.getDamage() + 1); this.getLevel().setBlock(this, this, false); } return Level.BLOCK_UPDATE_RANDOM; } } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (block.getId() != AIR) { return false; } Block down = this.down(); if (down.getId() == SUGARCANE_BLOCK) { this.getLevel().setBlock(block, new BlockSugarcane(), true); return true; } else if (down.getId() == GRASS || down.getId() == DIRT || down.getId() == SAND) { Block block0 = down.north(); Block block1 = down.south(); Block block2 = down.west(); Block block3 = down.east(); if ((block0 instanceof BlockWater) || (block1 instanceof BlockWater) || (block2 instanceof BlockWater) || (block3 instanceof BlockWater)) { this.getLevel().setBlock(block, new BlockSugarcane(), true); return true; } } return false; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
4,572
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockLeaves2.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockLeaves2.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemApple; import cn.nukkit.item.ItemBlock; /** * Created on 2015/12/1 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockLeaves2 extends BlockLeaves { public BlockLeaves2() { this(0); } public BlockLeaves2(int meta) { super(meta); } public String getName() { String[] names = new String[]{ "Oak Leaves", "Spruce Leaves", "Birch Leaves", "Jungle Leaves" }; return names[this.getDamage() & 0x01]; } @Override public int getId() { return LEAVES2; } @Override public Item[] getDrops(Item item) { if (item.isShears()) { return new Item[]{ toItem() }; } else { if ((int) ((Math.random()) * 200) == 0 && this.getDamage() == DARK_OAK) { return new Item[]{ new ItemApple() }; } if ((int) ((Math.random()) * 20) == 0) { return new Item[]{ new ItemBlock(new BlockSapling(), this.getDamage() & 0x03, 1) }; } } return new Item[0]; } }
1,330
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockOreIron.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockOreIron.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; /** * author: MagicDroidX * Nukkit Project */ public class BlockOreIron extends BlockSolid { public BlockOreIron() { } @Override public int getId() { return IRON_ORE; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 5; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Iron Ore"; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) { return new Item[]{ Item.get(IRON_ORE) }; } else { return new Item[0]; } } @Override public boolean canHarvestWithHand() { return false; } }
971
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSlab.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSlab.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockSlab extends BlockTransparentMeta { protected final int doubleSlab; public BlockSlab(int meta, int doubleSlab) { super(meta); this.doubleSlab = doubleSlab; } @Override public double getMinY() { return ((this.getDamage() & 0x08) > 0) ? this.y + 0.5 : this.y; } @Override public double getMaxY() { return ((this.getDamage() & 0x08) > 0) ? this.y + 1 : this.y + 0.5; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return getToolType() < ItemTool.TYPE_AXE ? 30 : 15; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.setDamage(this.getDamage() & 0x07); if (face == BlockFace.DOWN) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0x08 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } else { this.setDamage(this.getDamage() | 0x08); } } else if (face == BlockFace.UP) { if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true); return true; } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } //TODO: check for collision } else { if (block instanceof BlockSlab) { if ((block.getDamage() & 0x07) == (this.getDamage() & 0x07)) { this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true); return true; } return false; } else { if (fy > 0.5) { this.setDamage(this.getDamage() | 0x08); } } } if (block instanceof BlockSlab && (target.getDamage() & 0x07) != (this.getDamage() & 0x07)) { return false; } this.getLevel().setBlock(block, this, true, true); return true; } }
3,203
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockGlassPane.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockGlassPane.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/6 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockGlassPane extends BlockThin { public BlockGlassPane() { } @Override public String getName() { return "Glass Pane"; } @Override public int getId() { return GLASS_PANE; } @Override public double getResistance() { return 1.5; } @Override public double getHardness() { return 0.3; } @Override public Item[] getDrops(Item item) { return new Item[0]; } @Override public BlockColor getColor() { return BlockColor.AIR_BLOCK_COLOR; } }
759
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockMelon.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockMelon.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemMelon; import cn.nukkit.item.ItemTool; import cn.nukkit.item.enchantment.Enchantment; import cn.nukkit.utils.BlockColor; import java.util.Random; /** * Created on 2015/12/11 by Pub4Game. * Package cn.nukkit.block in project Nukkit . */ public class BlockMelon extends BlockSolid { public BlockMelon() { } @Override public int getId() { return MELON_BLOCK; } public String getName() { return "Melon Block"; } public double getHardness() { return 1; } @Override public double getResistance() { return 5; } @Override public Item[] getDrops(Item item) { Random random = new Random(); int count = 3 + random.nextInt(5); Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING); if (fortune != null && fortune.getLevel() >= 1) { count += random.nextInt(fortune.getLevel() + 1); } return new Item[]{ new ItemMelon(0, Math.min(9, count)) }; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
1,313
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockRedstoneComparator.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockRedstoneComparator.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityComparator; import cn.nukkit.item.Item; import cn.nukkit.item.ItemRedstoneComparator; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.ListTag; /** * @author CreeperFace */ public abstract class BlockRedstoneComparator extends BlockRedstoneDiode { public BlockRedstoneComparator() { this(0); } public BlockRedstoneComparator(int meta) { super(meta); } @Override protected int getDelay() { return 2; } @Override public BlockFace getFacing() { return BlockFace.fromHorizontalIndex(this.getDamage()); } public Mode getMode() { return (getDamage() & 4) > 0 ? Mode.SUBTRACT : Mode.COMPARE; } @Override protected BlockRedstoneComparator getUnpowered() { return new BlockRedstoneComparatorUnpowered(this.getDamage()); } @Override protected BlockRedstoneComparator getPowered() { return new BlockRedstoneComparatorPowered(this.getDamage()); } @Override protected int getRedstoneSignal() { BlockEntity blockEntity = this.level.getBlockEntity(this); return blockEntity instanceof BlockEntityComparator ? ((BlockEntityComparator) blockEntity).getOutputSignal() : 0; } @Override public void updateState() { if (!this.level.isBlockTickPending(this, this)) { int output = this.calculateOutput(); BlockEntity blockEntity = this.level.getBlockEntity(this); int power = blockEntity instanceof BlockEntityComparator ? ((BlockEntityComparator) blockEntity).getOutputSignal() : 0; if (output != power || this.isPowered() != this.shouldBePowered()) { /*if(isFacingTowardsRepeater()) { this.level.scheduleUpdate(this, this, 2, -1); } else { this.level.scheduleUpdate(this, this, 2, 0); }*/ //System.out.println("schedule update 0"); this.level.scheduleUpdate(this, this, 2); } } } protected int calculateInputStrength() { int power = super.calculateInputStrength(); BlockFace face = getFacing(); Block block = this.getSide(face); if (block.hasComparatorInputOverride()) { power = block.getComparatorInputOverride(); } else if (power < 15 && block.isNormalBlock()) { block = block.getSide(face); if (block.hasComparatorInputOverride()) { power = block.getComparatorInputOverride(); } } return power; } protected boolean shouldBePowered() { int input = this.calculateInputStrength(); if (input >= 15) { return true; } else if (input == 0) { return false; } else { int sidePower = this.getPowerOnSides(); return sidePower == 0 || input >= sidePower; } } private int calculateOutput() { return getMode() == Mode.SUBTRACT ? Math.max(this.calculateInputStrength() - this.getPowerOnSides(), 0) : this.calculateInputStrength(); } @Override public boolean onActivate(Item item, Player player) { if (getMode() == Mode.SUBTRACT) { this.setDamage(this.getDamage() - 4); } else { this.setDamage(this.getDamage() + 4); } this.level.addSound(this, Sound.RANDOM_CLICK, 1, getMode() == Mode.SUBTRACT ? 0.55F : 0.5F); this.level.setBlock(this, this, true, false); //bug? this.onChange(); return true; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_SCHEDULED) { this.onChange(); return type; } return super.onUpdate(type); } private void onChange() { int output = this.calculateOutput(); BlockEntity blockEntity = this.level.getBlockEntity(this); int currentOutput = 0; if (blockEntity instanceof BlockEntityComparator) { BlockEntityComparator blockEntityComparator = (BlockEntityComparator) blockEntity; currentOutput = blockEntityComparator.getOutputSignal(); blockEntityComparator.setOutputSignal(output); } if (currentOutput != output || getMode() == Mode.COMPARE) { boolean shouldBePowered = this.shouldBePowered(); boolean isPowered = this.isPowered(); if (isPowered && !shouldBePowered) { this.level.setBlock(this, getUnpowered(), true, false); } else if (!isPowered && shouldBePowered) { this.level.setBlock(this, getPowered(), true, false); } this.level.updateAroundRedstone(this, null); } } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (super.place(item, block, target, face, fx, fy, fz, player)) { CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.COMPARATOR) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); new BlockEntityComparator(this.level.getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); onUpdate(Level.BLOCK_UPDATE_REDSTONE); return true; } return false; } @Override public boolean isPowered() { return this.isPowered || (this.getDamage() & 8) > 0; } @Override public Item toItem() { return new ItemRedstoneComparator(); } public enum Mode { COMPARE, SUBTRACT } }
6,043
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEndGateway.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEndGateway.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.utils.BlockColor; /** * @author PikyCZ */ public class BlockEndGateway extends BlockSolid { public BlockEndGateway() { } @Override public String getName() { return "End Gateway"; } @Override public int getId() { return END_GATEWAY; } @Override public boolean canPassThrough() { return true; } @Override public boolean isBreakable(Item item) { return false; } @Override public double getHardness() { return -1; } @Override public double getResistance() { return 18000000; } @Override public int getLightLevel() { return 15; } @Override public boolean hasEntityCollision() { return true; } @Override public BlockColor getColor() { return BlockColor.AIR_BLOCK_COLOR; } }
1,000
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockFenceGateDarkOak.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockFenceGateDarkOak.java
package cn.nukkit.block; /** * Created on 2015/11/23 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockFenceGateDarkOak extends BlockFenceGate { public BlockFenceGateDarkOak() { this(0); } public BlockFenceGateDarkOak(int meta) { super(meta); } @Override public int getId() { return FENCE_GATE_DARK_OAK; } @Override public String getName() { return "Dark Oak Fence Gate"; } }
482
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStemMelon.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStemMelon.java
package cn.nukkit.block; import cn.nukkit.Server; import cn.nukkit.event.block.BlockGrowEvent; import cn.nukkit.item.Item; import cn.nukkit.item.ItemSeedsMelon; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.math.BlockFace.Plane; import cn.nukkit.math.NukkitRandom; /** * Created by Pub4Game on 15.01.2016. */ public class BlockStemMelon extends BlockCrops { public BlockStemMelon() { this(0); } public BlockStemMelon(int meta) { super(meta); } @Override public int getId() { return MELON_STEM; } @Override public String getName() { return "Melon Stem"; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().getId() != FARMLAND) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_RANDOM) { NukkitRandom random = new NukkitRandom(); if (random.nextRange(1, 2) == 1) { if (this.getDamage() < 0x07) { Block block = this.clone(); block.setDamage(block.getDamage() + 1); BlockGrowEvent ev = new BlockGrowEvent(this, block); Server.getInstance().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getNewState(), true); } return Level.BLOCK_UPDATE_RANDOM; } else { for (BlockFace face : Plane.HORIZONTAL) { Block b = this.getSide(face); if (b.getId() == MELON_BLOCK) { return Level.BLOCK_UPDATE_RANDOM; } } Block side = this.getSide(Plane.HORIZONTAL.random(random)); Block d = side.down(); if (side.getId() == AIR && (d.getId() == FARMLAND || d.getId() == GRASS || d.getId() == DIRT)) { BlockGrowEvent ev = new BlockGrowEvent(side, new BlockMelon()); Server.getInstance().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(side, ev.getNewState(), true); } } } } return Level.BLOCK_UPDATE_RANDOM; } return 0; } @Override public Item[] getDrops(Item item) { NukkitRandom random = new NukkitRandom(); return new Item[]{ new ItemSeedsMelon(0, random.nextRange(0, 3)) }; } }
2,815
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockLever.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockLever.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.event.block.BlockRedstoneEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; /** * @author Nukkit Project Team */ public class BlockLever extends BlockFlowable { public BlockLever() { this(0); } public BlockLever(int meta) { super(meta); } @Override public String getName() { return "Lever"; } @Override public int getId() { return LEVER; } @Override public boolean canBeActivated() { return true; } @Override public double getHardness() { return 0.5d; } @Override public double getResistance() { return 2.5d; } @Override public Item[] getDrops(Item item) { return new Item[]{toItem()}; } public boolean isPowerOn() { return (this.getDamage() & 0x08) > 0; } @Override public boolean onActivate(Item item, Player player) { this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, isPowerOn() ? 15 : 0, isPowerOn() ? 0 : 15)); this.setDamage(this.getDamage() ^ 0x08); this.getLevel().setBlock(this, this, false, true); this.getLevel().addSound(this, Sound.RANDOM_CLICK); //TODO: coorect pitcj LeverOrientation orientation = LeverOrientation.byMetadata(this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage()); BlockFace face = orientation.getFacing(); //this.level.updateAroundRedstone(this, null); this.level.updateAroundRedstone(this.getLocation().getSide(face.getOpposite()), isPowerOn() ? face : null); return true; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { int face = this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage(); BlockFace faces = LeverOrientation.byMetadata(face).getFacing().getOpposite(); if (!this.getSide(faces).isSolid()) { this.level.useBreakOn(this); } } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (target.isNormalBlock()) { this.setDamage(LeverOrientation.forFacings(face, player.getHorizontalFacing()).getMetadata()); this.getLevel().setBlock(block, this, true, true); return true; } return false; } @Override public boolean onBreak(Item item) { this.getLevel().setBlock(this, new BlockAir(), true, true); if (isPowerOn()) { BlockFace face = LeverOrientation.byMetadata(this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage()).getFacing(); this.level.updateAround(this.getLocation().getSide(face.getOpposite())); } return true; } @Override public int getWeakPower(BlockFace side) { return isPowerOn() ? 15 : 0; } public int getStrongPower(BlockFace side) { return !isPowerOn() ? 0 : LeverOrientation.byMetadata(this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage()).getFacing() == side ? 15 : 0; } @Override public boolean isPowerSource() { return true; } public enum LeverOrientation { DOWN_X(0, "down_x", BlockFace.DOWN), EAST(1, "east", BlockFace.EAST), WEST(2, "west", BlockFace.WEST), SOUTH(3, "south", BlockFace.SOUTH), NORTH(4, "north", BlockFace.NORTH), UP_Z(5, "up_z", BlockFace.UP), UP_X(6, "up_x", BlockFace.UP), DOWN_Z(7, "down_z", BlockFace.DOWN); private static final LeverOrientation[] META_LOOKUP = new LeverOrientation[values().length]; private final int meta; private final String name; private final BlockFace facing; LeverOrientation(int meta, String name, BlockFace face) { this.meta = meta; this.name = name; this.facing = face; } public int getMetadata() { return this.meta; } public BlockFace getFacing() { return this.facing; } public String toString() { return this.name; } public static LeverOrientation byMetadata(int meta) { if (meta < 0 || meta >= META_LOOKUP.length) { meta = 0; } return META_LOOKUP[meta]; } public static LeverOrientation forFacings(BlockFace clickedSide, BlockFace playerDirection) { switch (clickedSide) { case DOWN: switch (playerDirection.getAxis()) { case X: return DOWN_X; case Z: return DOWN_Z; default: throw new IllegalArgumentException("Invalid entityFacing " + playerDirection + " for facing " + clickedSide); } case UP: switch (playerDirection.getAxis()) { case X: return UP_X; case Z: return UP_Z; default: throw new IllegalArgumentException("Invalid entityFacing " + playerDirection + " for facing " + clickedSide); } case NORTH: return NORTH; case SOUTH: return SOUTH; case WEST: return WEST; case EAST: return EAST; default: throw new IllegalArgumentException("Invalid facing: " + clickedSide); } } public String getName() { return this.name; } static { for (LeverOrientation face : values()) { META_LOOKUP[face.getMetadata()] = face; } } } }
6,204
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDeadBush.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDeadBush.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemStick; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; import java.util.Random; /** * Created on 2015/12/2 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockDeadBush extends BlockFlowable { public BlockDeadBush() { this(0); } public BlockDeadBush(int meta) { super(meta); } @Override public String getName() { return "Dead Bush"; } @Override public int getId() { return DEAD_BUSH; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block down = this.down(); if (down.getId() == SAND || down.getId() == TERRACOTTA || down.getId() == STAINED_TERRACOTTA || down.getId() == PODZOL) { this.getLevel().setBlock(block, this, true, true); return true; } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().isTransparent()) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } return 0; } @Override public Item[] getDrops(Item item) { if (item.isShears()) { return new Item[]{ toItem() }; } else { return new Item[]{ new ItemStick(0, new Random().nextInt(3)) }; } } public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
1,769
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockCrops.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockCrops.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.event.block.BlockGrowEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.particle.BoneMealParticle; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; import java.util.Random; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockCrops extends BlockFlowable { protected BlockCrops(int meta) { super(meta); } @Override public boolean canBeActivated() { return true; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (block.down().getId() == FARMLAND) { this.getLevel().setBlock(block, this, true, true); return true; } return false; } @Override public boolean onActivate(Item item) { return this.onActivate(item, null); } @Override public boolean onActivate(Item item, Player player) { //Bone meal if (item.getId() == Item.DYE && item.getDamage() == 0x0f) { BlockCrops block = (BlockCrops) this.clone(); if (this.getDamage() < 7) { block.setDamage(block.getDamage() + new Random().nextInt(3) + 2); if (block.getDamage() > 7) { block.setDamage(7); } BlockGrowEvent ev = new BlockGrowEvent(this, block); Server.getInstance().getPluginManager().callEvent(ev); if (ev.isCancelled()) { return false; } this.getLevel().setBlock(this, ev.getNewState(), false, true); } this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5))); item.count--; return true; } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().getId() != FARMLAND) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_RANDOM) { if (new Random().nextInt(2) == 1) { if (this.getDamage() < 0x07) { BlockCrops block = (BlockCrops) this.clone(); block.setDamage(block.getDamage() + 1); BlockGrowEvent ev = new BlockGrowEvent(this, block); Server.getInstance().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { this.getLevel().setBlock(this, ev.getNewState(), false, true); } else { return Level.BLOCK_UPDATE_RANDOM; } } } else { return Level.BLOCK_UPDATE_RANDOM; } } return 0; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
3,328
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedPurple.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPurple.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedPurple extends BlockTerracottaGlazed { public BlockTerracottaGlazedPurple() { this(0); } public BlockTerracottaGlazedPurple(int meta) { super(meta); } @Override public int getId() { return PURPLE_GLAZED_TERRACOTTA; } @Override public String getName() { return "Purple Glazed Terracotta"; } }
475
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockPressurePlateWood.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockPressurePlateWood.java
package cn.nukkit.block; import cn.nukkit.entity.Entity; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.utils.BlockColor; /** * @author Nukkit Project Team */ public class BlockPressurePlateWood extends BlockPressurePlateBase { public BlockPressurePlateWood(int meta) { super(meta); this.onPitch = 0.8f; this.offPitch = 0.7f; } public BlockPressurePlateWood() { this(0); } @Override public String getName() { return "Wooden Pressure Plate"; } @Override public int getId() { return WOODEN_PRESSURE_PLATE; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public double getHardness() { return 0.5D; } @Override public double getResistance() { return 2.5D; } @Override public Item[] getDrops(Item item) { return new Item[]{ toItem() }; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } @Override protected int computeRedstoneStrength() { AxisAlignedBB bb = getCollisionBoundingBox(); for (Entity entity : this.level.getCollidingEntities(bb)) { if (entity.doesTriggerPressurePlate()) { return 15; } } return 0; } }
1,447
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedBlack.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlack.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedBlack extends BlockTerracottaGlazed { public BlockTerracottaGlazedBlack() { this(0); } public BlockTerracottaGlazedBlack(int meta) { super(meta); } @Override public int getId() { return BLACK_GLAZED_TERRACOTTA; } @Override public String getName() { return "Black Glazed Terracotta"; } }
470
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockRedstoneRepeaterPowered.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterPowered.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemRedstoneRepeater; import cn.nukkit.math.BlockFace; /** * Created by CreeperFace on 10.4.2017. */ public class BlockRedstoneRepeaterPowered extends BlockRedstoneDiode { public BlockRedstoneRepeaterPowered() { this(0); } public BlockRedstoneRepeaterPowered(int meta) { super(meta); this.isPowered = true; } @Override public int getId() { return POWERED_REPEATER; } @Override public String getName() { return "Powered Repeater"; } @Override public BlockFace getFacing() { return BlockFace.fromHorizontalIndex(getDamage()); } @Override protected boolean isAlternateInput(Block block) { return isDiode(block); } @Override public Item toItem() { return new ItemRedstoneRepeater(); } @Override protected int getDelay() { return (1 + (getDamage() >> 2)) * 2; } @Override protected Block getPowered() { return this; } @Override protected Block getUnpowered() { return new BlockRedstoneRepeaterUnpowered(this.getDamage()); } @Override public int getLightLevel() { return 7; } @Override public boolean onActivate(Item item, Player player) { this.setDamage(this.getDamage() + 4); if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4); this.level.setBlock(this, this, true, false); return true; } @Override public boolean isLocked() { return this.getPowerOnSides() > 0; } }
1,677
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockOreEmerald.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockOreEmerald.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemEmerald; import cn.nukkit.item.ItemTool; import cn.nukkit.item.enchantment.Enchantment; import cn.nukkit.math.NukkitRandom; import java.util.concurrent.ThreadLocalRandom; /** * Created on 2015/12/1 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockOreEmerald extends BlockSolid { public BlockOreEmerald() { } @Override public String getName() { return "Emerald Ore"; } @Override public int getId() { return EMERALD_ORE; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 15; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) { int count = 1; Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING); if (fortune != null && fortune.getLevel() >= 1) { int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1; if (i < 0) { i = 0; } count = i + 1; } return new Item[]{ new ItemEmerald(0, count) }; } else { return new Item[0]; } } @Override public int getDropExp() { return new NukkitRandom().nextRange(3, 7); } @Override public boolean canHarvestWithHand() { return false; } }
1,684
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoublePlant.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoublePlant.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemSeedsWheat; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; import java.util.Random; /** * Created on 2015/11/23 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockDoublePlant extends BlockFlowable { public BlockDoublePlant() { this(0); } public BlockDoublePlant(int meta) { super(meta); } @Override public int getId() { return DOUBLE_PLANT; } @Override public boolean canBeReplaced() { return this.getDamage() == 2 || this.getDamage() == 3; } @Override public String getName() { String[] names = new String[]{ "Sunflower", "Lilac", "Double Tallgrass", "Large Fern", "Rose Bush", "Peony" }; return names[this.getDamage() & 0x07]; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if ((this.getDamage() & 0x08) == 8) { // Top if (!(this.down().getId() == DOUBLE_PLANT)) { this.getLevel().setBlock(this, new BlockAir(), false, true); return Level.BLOCK_UPDATE_NORMAL; } } else { // Bottom if (this.down().isTransparent() || !(this.up().getId() == DOUBLE_PLANT)) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block down = down(); Block up = up(); if (up.getId() == 0 && (down.getId() == GRASS || down.getId() == DIRT)) { this.getLevel().setBlock(block, this, true, false); // If we update the bottom half, it will drop the item because there isn't a flower block above this.getLevel().setBlock(up, new BlockDoublePlant(getDamage() ^ 0x08), true, true); return true; } return false; } @Override public boolean onBreak(Item item) { Block down = down(); if ((this.getDamage() & 0x08) == 0x08) { // Top half this.getLevel().useBreakOn(down); } else { this.getLevel().setBlock(this, new BlockAir(), true, true); } return true; } @Override public Item[] getDrops(Item item) { if ((this.getDamage() & 0x08) != 0x08) { switch (this.getDamage() & 0x07) { case 2: case 3: boolean dropSeeds = new Random().nextInt(10) == 0; if (item.isShears()) { //todo enchantment if (dropSeeds) { return new Item[]{ new ItemSeedsWheat(0, 1), toItem() }; } else { return new Item[]{ toItem() }; } } if (dropSeeds) { return new Item[]{ new ItemSeedsWheat() }; } else { return new Item[0]; } } return new Item[]{toItem()}; } return new Item[0]; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
3,894
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracottaGlazedRed.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracottaGlazedRed.java
package cn.nukkit.block; /** * Created by CreeperFace on 2.6.2017. */ public class BlockTerracottaGlazedRed extends BlockTerracottaGlazed { public BlockTerracottaGlazedRed() { this(0); } public BlockTerracottaGlazedRed(int meta) { super(meta); } @Override public int getId() { return RED_GLAZED_TERRACOTTA; } @Override public String getName() { return "Red Glazed Terracotta"; } }
460
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockFenceGate.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockFenceGate.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.event.block.DoorToggleEvent; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/23 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockFenceGate extends BlockTransparentMeta { public BlockFenceGate() { this(0); } public BlockFenceGate(int meta) { super(meta); } @Override public int getId() { return FENCE_GATE_OAK; } @Override public String getName() { return "Oak Fence Gate"; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 15; } @Override public boolean canBeActivated() { return true; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } private static final double[] offMinX = new double[2]; private static final double[] offMinZ = new double[2]; private static final double[] offMaxX = new double[2]; private static final double[] offMaxZ = new double[2]; static { offMinX[0] = 0; offMinZ[0] = 0.375; offMaxX[0] = 1; offMaxZ[0] = 0.625; offMinX[1] = 0.375; offMinZ[1] = 0; offMaxX[1] = 0.625; offMaxZ[1] = 1; } private int getOffsetIndex() { switch (this.getDamage() & 0x03) { case 0: case 2: return 0; default: return 1; } } @Override public double getMinX() { return this.x + offMinX[getOffsetIndex()]; } @Override public double getMinZ() { return this.z + offMinZ[getOffsetIndex()]; } @Override public double getMaxX() { return this.x + offMaxX[getOffsetIndex()]; } @Override public double getMaxZ() { return this.z + offMaxZ[getOffsetIndex()]; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.setDamage(player != null ? player.getDirection().getHorizontalIndex() : 0); this.getLevel().setBlock(block, this, true, true); return true; } @Override public boolean onActivate(Item item, Player player) { if (player == null) { return false; } if (!this.toggle(player)) { return false; } this.level.addSound(this, isOpen() ? Sound.RANDOM_DOOR_OPEN : Sound.RANDOM_DOOR_CLOSE); return true; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } public boolean toggle(Player player) { DoorToggleEvent event = new DoorToggleEvent(this, player); this.getLevel().getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } player = event.getPlayer(); int direction; if (player != null) { double yaw = player.yaw; double rotation = (yaw - 90) % 360; if (rotation < 0) { rotation += 360.0; } int originDirection = this.getDamage() & 0x01; if (originDirection == 0) { if (rotation >= 0 && rotation < 180) { direction = 2; } else { direction = 0; } } else { if (rotation >= 90 && rotation < 270) { direction = 3; } else { direction = 1; } } } else { int originDirection = this.getDamage() & 0x01; if (originDirection == 0) { direction = 0; } else { direction = 1; } } this.setDamage(direction | ((~this.getDamage()) & 0x04)); this.level.setBlock(this, this, false, false); return true; } public boolean isOpen() { return (this.getDamage() & 0x04) > 0; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_REDSTONE) { if ((!isOpen() && this.level.isBlockPowered(this)) || (isOpen() && !this.level.isBlockPowered(this))) { this.toggle(null); return type; } } return 0; } }
4,645
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockWaterLily.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockWaterLily.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.level.Level; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/1 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockWaterLily extends BlockFlowable { public BlockWaterLily() { this(0); } public BlockWaterLily(int meta) { super(meta); } @Override public String getName() { return "Lily Pad"; } @Override public int getId() { return WATER_LILY; } @Override public double getMinX() { return this.x + 0.0625; } @Override public double getMinZ() { return this.z + 0.0625; } @Override public double getMaxX() { return this.x + 0.9375; } @Override public double getMaxY() { return this.y + 0.015625; } @Override public double getMaxZ() { return this.z + 0.9375; } @Override protected AxisAlignedBB recalculateBoundingBox() { return this; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (target instanceof BlockWater) { Block up = target.up(); if (up.getId() == Block.AIR) { this.getLevel().setBlock(up, this, true, true); return true; } } return false; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (!(this.down() instanceof BlockWater)) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } return 0; } @Override public Item toItem() { return new ItemBlock(this, 0); } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } @Override public boolean canPassThrough() { return false; } }
2,163
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockSapling.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockSapling.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.generator.object.BasicGenerator; import cn.nukkit.level.generator.object.tree.*; import cn.nukkit.level.particle.BoneMealParticle; import cn.nukkit.math.BlockFace; import cn.nukkit.math.NukkitRandom; import cn.nukkit.math.Vector3; import cn.nukkit.utils.BlockColor; import java.util.concurrent.ThreadLocalRandom; /** * author: Angelic47 * Nukkit Project */ public class BlockSapling extends BlockFlowable { public static final int OAK = 0; public static final int SPRUCE = 1; public static final int BIRCH = 2; public static final int JUNGLE = 3; public static final int ACACIA = 4; public static final int DARK_OAK = 5; public BlockSapling() { this(0); } public BlockSapling(int meta) { super(meta); } @Override public int getId() { return SAPLING; } @Override public String getName() { String[] names = new String[]{ "Oak Sapling", "Spruce Sapling", "Birch Sapling", "Jungle Sapling", "Acacia Sapling", "Dark Oak Sapling", "", "" }; return names[this.getDamage() & 0x07]; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Block down = this.down(); if (down.getId() == Block.GRASS || down.getId() == Block.DIRT || down.getId() == Block.FARMLAND || down.getId() == Block.PODZOL) { this.getLevel().setBlock(block, this, true, true); return true; } return false; } @Override public boolean canBeActivated() { return true; } public boolean onActivate(Item item, Player player) { if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //BoneMeal if ((player.gamemode & 0x01) == 0) { item.count--; } this.level.addParticle(new BoneMealParticle(this)); if (ThreadLocalRandom.current().nextFloat() >= 0.45) { return true; } BasicGenerator generator = null; boolean bigTree = false; int x = 0; int z = 0; switch (this.getDamage()) { case JUNGLE: loop: for (x = 0; x >= -1; --x) { for (z = 0; z >= -1; --z) { if (this.findSaplings(x, z, JUNGLE)) { generator = new ObjectJungleBigTree(10, 20, new BlockWood(BlockWood.JUNGLE), new BlockLeaves(BlockLeaves.JUNGLE)); bigTree = true; break loop; } } } if (!bigTree) { generator = new NewJungleTree(4 + ThreadLocalRandom.current().nextInt(7)); } break; case ACACIA: generator = new ObjectSavannaTree(); break; case DARK_OAK: bigTree = false; loop: for (x = 0; x >= -1; --x) { for (z = 0; z >= -1; --z) { if (this.findSaplings(x, z, DARK_OAK)) { generator = new ObjectDarkOakTree(); bigTree = true; break loop; } } } if (!bigTree) { return false; } break; //TODO: big spruce default: ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.getDamage() & 0x07); return true; } BlockAir air = new BlockAir(); if (bigTree) { this.level.setBlock(this.add(x, 0, z), air, true, false); this.level.setBlock(this.add(x + 1, 0, z), air, true, false); this.level.setBlock(this.add(x, 0, z + 1), air, true, false); this.level.setBlock(this.add(x + 1, 0, z + 1), air, true, false); } else { this.level.setBlock(this, air, true, false); } if (!generator.generate(this.level, new NukkitRandom(), this.add(x, 0, z))) { if (bigTree) { this.level.setBlock(this.add(x, 0, z), this, true, false); this.level.setBlock(this.add(x + 1, 0, z), this, true, false); this.level.setBlock(this.add(x, 0, z + 1), this, true, false); this.level.setBlock(this.add(x + 1, 0, z + 1), this, true, false); } else { this.level.setBlock(this, this, true, false); } } return true; } return false; } public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().isTransparent()) { this.getLevel().useBreakOn(this); return Level.BLOCK_UPDATE_NORMAL; } } else if (type == Level.BLOCK_UPDATE_RANDOM) { //Growth if (new NukkitRandom().nextRange(1, 7) == 1) { if ((this.getDamage() & 0x08) == 0x08) { ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.getDamage() & 0x07); } else { this.setDamage(this.getDamage() | 0x08); this.getLevel().setBlock(this, this, true); return Level.BLOCK_UPDATE_RANDOM; } } else { return Level.BLOCK_UPDATE_RANDOM; } } return 1; } private boolean findSaplings(int x, int z, int type) { return this.isSameType(this.add(x, 0, z), type) && this.isSameType(this.add(x + 1, 0, z), type) && this.isSameType(this.add(x, 0, z + 1), type) && this.isSameType(this.add(x + 1, 0, z + 1), type); } public boolean isSameType(Vector3 pos, int type) { Block block = this.level.getBlock(pos); return block.getId() == this.getId() && block.getDamage() == type; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } }
6,767
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoor.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoor.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.event.block.BlockRedstoneEvent; import cn.nukkit.event.block.DoorToggleEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.AxisAlignedBB; import cn.nukkit.math.BlockFace; import cn.nukkit.math.SimpleAxisAlignedBB; /** * author: MagicDroidX * Nukkit Project */ public abstract class BlockDoor extends BlockTransparentMeta { protected BlockDoor(int meta) { super(meta); } @Override public boolean canBeActivated() { return true; } @Override public boolean isSolid() { return false; } @Override public boolean canPassThrough() { return true; } private int getFullDamage() { int damage = this.getDamage(); boolean isUp = (damage & 0x08) > 0; int up; int down; if (isUp) { down = this.down().getDamage(); up = damage; } else { down = damage; up = this.up().getDamage(); } boolean isRight = (up & 0x01) > 0; return down & 0x07 | (isUp ? 8 : 0) | (isRight ? 0x10 : 0); } @Override protected AxisAlignedBB recalculateBoundingBox() { double f = 0.1875; int damage = this.getFullDamage(); AxisAlignedBB bb = new SimpleAxisAlignedBB( this.x, this.y, this.z, this.x + 1, this.y + 2, this.z + 1 ); int j = damage & 0x03; boolean isOpen = ((damage & 0x04) > 0); boolean isRight = ((damage & 0x10) > 0); if (j == 0) { if (isOpen) { if (!isRight) { bb.setBounds( this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f ); } else { bb.setBounds( this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1 ); } } else { bb.setBounds( this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1 ); } } else if (j == 1) { if (isOpen) { if (!isRight) { bb.setBounds( this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1 ); } else { bb.setBounds( this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1 ); } } else { bb.setBounds( this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f ); } } else if (j == 2) { if (isOpen) { if (!isRight) { bb.setBounds( this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1 ); } else { bb.setBounds( this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f ); } } else { bb.setBounds( this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1 ); } } else if (j == 3) { if (isOpen) { if (!isRight) { bb.setBounds( this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1 ); } else { bb.setBounds( this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1 ); } } else { bb.setBounds( this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1 ); } } return bb; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.down().getId() == AIR) { Block up = this.up(); if (up instanceof BlockDoor) { this.getLevel().setBlock(up, new BlockAir(), false); this.getLevel().useBreakOn(this); } return Level.BLOCK_UPDATE_NORMAL; } } if (type == Level.BLOCK_UPDATE_REDSTONE) { if ((!isOpen() && this.level.isBlockPowered(this)) || (isOpen() && !this.level.isBlockPowered(this))) { this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, isOpen() ? 15 : 0, isOpen() ? 0 : 15)); this.toggle(null); } } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz) { return this.place(item, block, target, face, fx, fy, fz, null); } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (face == BlockFace.UP) { Block blockUp = this.up(); Block blockDown = this.down(); if (!blockUp.canBeReplaced() || blockDown.isTransparent()) { return false; } int[] faces = {1, 2, 3, 0}; int direction = faces[player != null ? player.getDirection().getHorizontalIndex() : 0]; Block left = this.getSide(player.getDirection().rotateYCCW()); Block right = this.getSide(player.getDirection().rotateY()); int metaUp = 0x08; if (left.getId() == this.getId() || (!right.isTransparent() && left.isTransparent())) { //Door hinge metaUp |= 0x01; } this.setDamage(direction); this.getLevel().setBlock(block, this, true, true); //Bottom this.getLevel().setBlock(blockUp, Block.get(this.getId(), metaUp), true); //Top if (!this.isOpen() && this.level.isBlockPowered(this)) { this.toggle(null); } return true; } return false; } @Override public boolean onBreak(Item item) { if ((this.getDamage() & 0x08) == 0x08) { Block down = this.down(); if (down.getId() == this.getId()) { this.getLevel().setBlock(down, new BlockAir(), true); } } else { Block up = this.up(); if (up.getId() == this.getId()) { this.getLevel().setBlock(up, new BlockAir(), true); } } this.getLevel().setBlock(this, new BlockAir(), true); return true; } @Override public boolean onActivate(Item item) { return this.onActivate(item, null); } @Override public boolean onActivate(Item item, Player player) { if (!this.toggle(player)) { return false; } this.level.addSound(this, isOpen() ? Sound.RANDOM_DOOR_OPEN : Sound.RANDOM_DOOR_CLOSE); return true; } public boolean toggle(Player player) { DoorToggleEvent event = new DoorToggleEvent(this, player); this.getLevel().getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } if (isTop(this.getDamage())) { //Top Block down = this.down(); if (down.getId() != this.getId()) { return false; } this.getLevel().setBlock(down, Block.get(this.getId(), down.getDamage() ^ 0x04), true); this.setDamage(this.getDamage() ^ 0x04); this.getLevel().setBlock(this, this, true); } else { //Down Block up = this.up(); if (up.getId() != this.getId()) { return false; } this.setDamage(this.getDamage() ^ 0x04); this.getLevel().setBlock(this, this, true); } return true; } public boolean isOpen() { return (this.getDamage() & 0x04) > 0; } public boolean isTop(int meta) { return (meta & 8) != 0; } }
10,044
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTripWireHook.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTripWireHook.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.event.block.BlockRedstoneEvent; import cn.nukkit.item.Item; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.math.Vector3; import cn.nukkit.network.protocol.LevelSoundEventPacket; /** * @author CreeperFace */ public class BlockTripWireHook extends BlockFlowable { public BlockTripWireHook() { this(0); } public BlockTripWireHook(int meta) { super(meta); } @Override public String getName() { return "Tripwire Hook"; } @Override public int getId() { return TRIPWIRE_HOOK; } public BlockFace getFacing() { return BlockFace.fromHorizontalIndex(getDamage() & 0b11); } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (!this.getSide(this.getFacing().getOpposite()).isNormalBlock()) { this.level.useBreakOn(this); } return type; } else if (type == Level.BLOCK_UPDATE_SCHEDULED) { this.calculateState(false, true, -1, null); return type; } return 0; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (!this.getSide(face.getOpposite()).isNormalBlock()) { return false; } if (face.getAxis().isHorizontal()) { this.setFace(face); } this.level.setBlock(this, this); if (player != null) { this.calculateState(false, false, -1, null); } return true; } @Override public boolean onBreak(Item item) { super.onBreak(item); boolean attached = isAttached(); boolean powered = isPowered(); if (attached || powered) { this.calculateState(true, false, -1, null); } if (powered) { this.level.updateAroundRedstone(this, null); this.level.updateAroundRedstone(this.getLocation().getSide(getFacing().getOpposite()), null); } return true; } public void calculateState(boolean onBreak, boolean updateAround, int pos, Block block) { BlockFace facing = getFacing(); Vector3 v = this.getLocation(); boolean attached = isAttached(); boolean powered = isPowered(); boolean canConnect = !onBreak; boolean nextPowered = false; int distance = 0; Block[] blocks = new Block[42]; for (int i = 1; i < 42; ++i) { Vector3 vector = v.getSide(facing, i); Block b = this.level.getBlock(vector); if (b instanceof BlockTripWireHook) { if (((BlockTripWireHook) b).getFacing() == facing.getOpposite()) { distance = i; } break; } if (b.getId() != Block.TRIPWIRE && i != pos) { blocks[i] = null; canConnect = false; } else { if (i == pos) { b = block != null ? block : b; } if (b instanceof BlockTripWire) { boolean disarmed = !((BlockTripWire) b).isDisarmed(); boolean wirePowered = ((BlockTripWire) b).isPowered(); nextPowered |= disarmed && wirePowered; if (i == pos) { this.level.scheduleUpdate(this, 10); canConnect &= disarmed; } } blocks[i] = b; } } canConnect = canConnect & distance > 1; nextPowered = nextPowered & canConnect; BlockTripWireHook hook = new BlockTripWireHook(); hook.setAttached(canConnect); hook.setPowered(nextPowered); if (distance > 0) { Vector3 vec = v.getSide(facing, distance); BlockFace face = facing.getOpposite(); hook.setFace(face); this.level.setBlock(vec, hook, true, false); this.level.updateAroundRedstone(vec, null); this.level.updateAroundRedstone(vec.getSide(face.getOpposite()), null); this.addSound(vec, canConnect, nextPowered, attached, powered); } this.addSound(v, canConnect, nextPowered, attached, powered); if (!onBreak) { hook.setFace(facing); this.level.setBlock(v, hook, true, false); if (updateAround) { this.level.updateAroundRedstone(v, null); this.level.updateAroundRedstone(v.getSide(facing.getOpposite()), null); } } if (attached != canConnect) { for (int i = 1; i < distance; i++) { Vector3 vc = v.getSide(facing, i); block = blocks[i]; if (block != null && this.level.getBlockIdAt(vc.getFloorX(), vc.getFloorY(), vc.getFloorZ()) != Block.AIR) { if (canConnect ^ ((block.getDamage() & 0x04) > 0)) { block.setDamage(block.getDamage() ^ 0x04); } this.level.setBlock(vc, block, true, false); } } } } private void addSound(Vector3 pos, boolean canConnect, boolean nextPowered, boolean attached, boolean powered) { if (nextPowered && !powered) { this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_POWER_ON, 1, -1); this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15)); } else if (!nextPowered && powered) { this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_POWER_OFF, 1, -1); this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0)); } else if (canConnect && !attached) { this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_ATTACH, 1, -1); } else if (!canConnect && attached) { this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_DETACH, 1, -1); } } public boolean isAttached() { return (getDamage() & 0x04) > 0; } public boolean isPowered() { return (this.getDamage() & 0x08) > 0; } public void setPowered(boolean value) { if (value ^ this.isPowered()) { this.setDamage(this.getDamage() ^ 0x08); } } public void setAttached(boolean value) { if (value ^ this.isAttached()) { this.setDamage(this.getDamage() ^ 0x04); } } public void setFace(BlockFace face) { this.setDamage(this.getDamage() - this.getDamage() % 4); this.setDamage(this.getDamage() | face.getHorizontalIndex()); } @Override public boolean isPowerSource() { return true; } @Override public int getWeakPower(BlockFace face) { return isPowered() ? 15 : 0; } @Override public int getStrongPower(BlockFace side) { return !isPowered() ? 0 : getFacing() == side ? 15 : 0; } }
7,216
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockRailDetector.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockRailDetector.java
package cn.nukkit.block; import cn.nukkit.entity.Entity; import cn.nukkit.entity.item.EntityMinecartAbstract; import cn.nukkit.level.Level; import cn.nukkit.math.BlockFace; import cn.nukkit.math.SimpleAxisAlignedBB; /** * Created on 2015/11/22 by CreeperFace. * Contributed by: larryTheCoder on 2017/7/8. * <p> * Nukkit Project, * Minecart and Riding Project, * Package cn.nukkit.block in project Nukkit. */ public class BlockRailDetector extends BlockRail { public BlockRailDetector() { this(0); canBePowered = true; } public BlockRailDetector(int meta) { super(meta); } @Override public int getId() { return DETECTOR_RAIL; } @Override public String getName() { return "Detector Rail"; } @Override public boolean isPowerSource() { return true; } @Override public int getWeakPower(BlockFace side) { return isActive() ? 15 : 0; } @Override public int getStrongPower(BlockFace side) { return isActive() ? 0 : (side == BlockFace.UP ? 15 : 0); } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_SCHEDULED) { updateState(); return type; } return super.onUpdate(type); } @Override public void onEntityCollide(Entity entity) { updateState(); } protected void updateState() { boolean wasPowered = isActive(); boolean isPowered = false; for (Entity entity : level.getNearbyEntities(new SimpleAxisAlignedBB( getFloorX() + 0.125D, getFloorY(), getFloorZ() + 0.125D, getFloorX() + 0.875D, getFloorY() + 0.525D, getFloorZ() + 0.875D))) { if (entity instanceof EntityMinecartAbstract) { isPowered = true; } } if (isPowered && !wasPowered) { setActive(true); level.scheduleUpdate(this, this, 0); level.scheduleUpdate(this, this.down(), 0); } if (!isPowered && wasPowered) { setActive(false); level.scheduleUpdate(this, this, 0); level.scheduleUpdate(this, this.down(), 0); } level.updateComparatorOutputLevel(this); } }
2,360
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockGlassStained.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockGlassStained.java
package cn.nukkit.block; import cn.nukkit.utils.BlockColor; import cn.nukkit.utils.DyeColor; /** * Created by CreeperFace on 7.8.2017. */ public class BlockGlassStained extends BlockGlass { private int meta; public BlockGlassStained() { this(0); } public BlockGlassStained(int meta) { this.meta = meta; } @Override public int getFullId() { return (getId() << 4) + getDamage(); } @Override public int getId() { return STAINED_GLASS; } @Override public String getName() { return getDyeColor().getName() + " Stained Glass"; } @Override public BlockColor getColor() { return DyeColor.getByWoolData(getDamage()).getColor(); } public DyeColor getDyeColor() { return DyeColor.getByWoolData(getDamage()); } @Override public final int getDamage() { return this.meta; } @Override public final void setDamage(int meta) { this.meta = meta; } }
1,018
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsWood.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsWood.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsWood extends BlockStairs { public BlockStairsWood() { this(0); } public BlockStairsWood(int meta) { super(meta); } @Override public int getId() { return WOOD_STAIRS; } @Override public String getName() { return "Wood Stairs"; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public Item toItem() { return new ItemBlock(this, 0); } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 15; } @Override public int getBurnChance() { return 5; } @Override public int getBurnAbility() { return 20; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } }
1,142
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsStoneBrick.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsStoneBrick.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsStoneBrick extends BlockStairs { public BlockStairsStoneBrick() { this(0); } public BlockStairsStoneBrick(int meta) { super(meta); } @Override public int getId() { return STONE_BRICK_STAIRS; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 1.5; } @Override public double getResistance() { return 30; } @Override public String getName() { return "Stone Brick Stairs"; } }
751
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockItemFrame.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockItemFrame.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.blockentity.BlockEntity; import cn.nukkit.blockentity.BlockEntityItemFrame; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.item.ItemItemFrame; import cn.nukkit.level.Level; import cn.nukkit.level.Sound; import cn.nukkit.math.BlockFace; import cn.nukkit.nbt.tag.CompoundTag; import cn.nukkit.nbt.tag.Tag; import java.util.Random; /** * Created by Pub4Game on 03.07.2016. */ public class BlockItemFrame extends BlockTransparentMeta { public BlockItemFrame() { this(0); } public BlockItemFrame(int meta) { super(meta); } @Override public int getId() { return ITEM_FRAME_BLOCK; } @Override public String getName() { return "Item Frame"; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { if (this.getSide(getFacing()).isTransparent()) { this.level.useBreakOn(this); return type; } } return 0; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = this.getLevel().getBlockEntity(this); BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity; if (itemFrame.getItem().getId() == Item.AIR) { // We can't use Item.get(item.getId(), item.getDamage(), 1) because // we need to keep the item's NBT tags Item itemOnFrame = item.clone(); // So we clone the item itemOnFrame.setCount(1); // Change it to only one item (if we keep +1, visual glitches will happen) itemFrame.setItem(itemOnFrame); // And then we set it on the item frame // The item will be removed from the player's hand a few lines ahead this.getLevel().addSound(this, Sound.BLOCK_ITEMFRAME_ADD_ITEM); if (player != null && player.isSurvival()) { int count = item.getCount(); if (count-- <= 0) { player.getInventory().setItemInHand(new ItemBlock(new BlockAir(), 0, 0)); return true; } item.setCount(count); player.getInventory().setItemInHand(item); } } else { int itemRot = itemFrame.getItemRotation(); if (itemRot >= 7) { itemRot = 0; } else { itemRot++; } itemFrame.setItemRotation(itemRot); this.getLevel().addSound(this, Sound.BLOCK_ITEMFRAME_ROTATE_ITEM); } return true; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { if (!target.isTransparent() && face.getIndex() > 1 && !block.isSolid()) { switch (face) { case NORTH: this.setDamage(3); break; case SOUTH: this.setDamage(2); break; case WEST: this.setDamage(1); break; case EAST: this.setDamage(0); break; default: return false; } this.getLevel().setBlock(block, this, true, true); CompoundTag nbt = new CompoundTag() .putString("id", BlockEntity.ITEM_FRAME) .putInt("x", (int) block.x) .putInt("y", (int) block.y) .putInt("z", (int) block.z) .putByte("ItemRotation", 0) .putFloat("ItemDropChance", 1.0f); if (item.hasCustomBlockData()) { for (Tag aTag : item.getCustomBlockData().getAllTags()) { nbt.put(aTag.getName(), aTag); } } new BlockEntityItemFrame(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); this.getLevel().addSound(this, Sound.BLOCK_ITEMFRAME_PLACE); return true; } return false; } @Override public boolean onBreak(Item item) { this.getLevel().setBlock(this, new BlockAir(), true, true); this.getLevel().addSound(this, Sound.BLOCK_ITEMFRAME_REMOVE_ITEM); return true; } @Override public Item[] getDrops(Item item) { BlockEntity blockEntity = this.getLevel().getBlockEntity(this); BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity; int chance = new Random().nextInt(100) + 1; if (itemFrame != null && chance <= (itemFrame.getItemDropChance() * 100)) { return new Item[]{ toItem(), Item.get(itemFrame.getItem().getId(), itemFrame.getItem().getDamage(), 1) }; } else { return new Item[]{ toItem() }; } } @Override public Item toItem() { return new ItemItemFrame(); } @Override public boolean canPassThrough() { return true; } @Override public boolean hasComparatorInputOverride() { return true; } @Override public int getComparatorInputOverride() { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityItemFrame) { return ((BlockEntityItemFrame) blockEntity).getAnalogOutput(); } return super.getComparatorInputOverride(); } public BlockFace getFacing() { switch (this.getDamage() % 8) { case 0: return BlockFace.WEST; case 1: return BlockFace.EAST; case 2: return BlockFace.NORTH; case 3: return BlockFace.SOUTH; } return null; } }
6,090
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockHayBale.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockHayBale.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/24 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockHayBale extends BlockSolid { public BlockHayBale() { } @Override public int getId() { return HAY_BALE; } @Override public String getName() { return "Hay Bale"; } @Override public double getHardness() { return 0.5; } @Override public double getResistance() { return 2.5; } @Override public int getBurnChance() { return 60; } @Override public int getBurnAbility() { return 20; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { int[] faces = new int[]{ 0, 0, 0b1000, 0b1000, 0b0100, 0b0100, }; this.setDamage((this.getDamage() & 0x03) | faces[face.getIndex()]); this.getLevel().setBlock(block, this, true, true); return true; } @Override public BlockColor getColor() { return BlockColor.GRASS_BLOCK_COLOR; } }
1,355
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockPumpkin.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockPumpkin.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.math.BlockFace; import cn.nukkit.utils.BlockColor; /** * Created on 2015/12/8 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockPumpkin extends BlockSolidMeta { public BlockPumpkin() { this(0); } public BlockPumpkin(int meta) { super(meta); } @Override public String getName() { return "Pumpkin"; } @Override public int getId() { return PUMPKIN; } @Override public double getHardness() { return 1; } @Override public double getResistance() { return 5; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { this.setDamage(player != null ? player.getDirection().getOpposite().getHorizontalIndex() : 0); this.getLevel().setBlock(block, this, true, true); return true; } @Override public BlockColor getColor() { return BlockColor.FOLIAGE_BLOCK_COLOR; } @Override public boolean canBePushed() { return false; } }
1,332
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; /** * author: MagicDroidX * Nukkit Project */ public class BlockStone extends BlockSolidMeta { public static final int NORMAL = 0; public static final int GRANITE = 1; public static final int POLISHED_GRANITE = 2; public static final int DIORITE = 3; public static final int POLISHED_DIORITE = 4; public static final int ANDESITE = 5; public static final int POLISHED_ANDESITE = 6; public BlockStone() { this(0); } public BlockStone(int meta) { super(meta); } @Override public int getId() { return STONE; } @Override public double getHardness() { return 1.5; } @Override public double getResistance() { return 10; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { String[] names = new String[]{ "Stone", "Granite", "Polished Granite", "Diorite", "Polished Diorite", "Andesite", "Polished Andesite", "Unknown Stone" }; return names[this.getDamage() & 0x07]; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ Item.get(this.getDamage() == 0 ? Item.COBBLESTONE : Item.STONE, this.getDamage(), 1) }; } else { return new Item[0]; } } @Override public boolean canHarvestWithHand() { return false; } }
1,751
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockBone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockBone.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemBlock; import cn.nukkit.item.ItemTool; /** * @author CreeperFace */ public class BlockBone extends BlockSolidMeta { public BlockBone() { this(0); } public BlockBone(int meta) { super(meta); } @Override public int getId() { return BONE_BLOCK; } @Override public String getName() { return "Bone Block"; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 10; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{new ItemBlock(this)}; } return new Item[0]; } }
929
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockIce.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockIce.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.level.Level; import cn.nukkit.utils.BlockColor; /** * author: MagicDroidX * Nukkit Project */ public class BlockIce extends BlockTransparent { public BlockIce() { } @Override public int getId() { return ICE; } @Override public String getName() { return "Ice"; } @Override public double getResistance() { return 2.5; } @Override public double getHardness() { return 0.5; } @Override public double getFrictionFactor() { return 0.98; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public boolean onBreak(Item item) { this.getLevel().setBlock(this, new BlockWater(), true); return true; } @Override public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_RANDOM) { if (this.getLevel().getBlockLightAt((int) this.x, (int) this.y, (int) this.z) >= 12) { this.getLevel().setBlock(this, new BlockWater(), true); return Level.BLOCK_UPDATE_NORMAL; } } return 0; } @Override public Item[] getDrops(Item item) { return new Item[0]; } @Override public BlockColor getColor() { return BlockColor.ICE_BLOCK_COLOR; } }
1,449
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockTerracotta.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockTerracotta.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; import cn.nukkit.utils.DyeColor; /** * Created on 2015/11/24 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockTerracotta extends BlockSolidMeta { public BlockTerracotta() { this(0); } public BlockTerracotta(int meta) { super(0); } public BlockTerracotta(DyeColor dyeColor) { this(dyeColor.getWoolData()); } @Override public int getId() { return TERRACOTTA; } @Override public String getName() { return "Terracotta"; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public double getHardness() { return 1.25; } @Override public double getResistance() { return 7; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { return new Item[]{ toItem() }; } else { return new Item[0]; } } @Override public BlockColor getColor() { return DyeColor.getByWoolData(getDamage()).getColor(); } public DyeColor getDyeColor() { return DyeColor.getByWoolData(getDamage()); } }
1,389
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockEndPortalFrame.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockEndPortalFrame.java
package cn.nukkit.block; import cn.nukkit.Player; import cn.nukkit.item.Item; /** * Created by Pub4Game on 26.12.2015. */ public class BlockEndPortalFrame extends BlockTransparentMeta { public BlockEndPortalFrame() { this(0); } public BlockEndPortalFrame(int meta) { super(meta); } @Override public int getId() { return END_PORTAL_FRAME; } @Override public double getResistance() { return 18000000; } @Override public double getHardness() { return -1; } @Override public int getLightLevel() { return 1; } @Override public String getName() { return "End Portal Frame"; } @Override public boolean isBreakable(Item item) { return false; } @Override public double getMaxY() { return this.y + ((this.getDamage() & 0x04) > 0 ? 1 : 0.8125); } @Override public boolean canBePushed() { return false; } public boolean hasComparatorInputOverride() { return true; } public int getComparatorInputOverride() { return (getDamage() & 4) != 0 ? 15 : 0; } @Override public boolean canBeActivated() { return true; } @Override public boolean onActivate(Item item, Player player) { //TODO: ender eye //TODO: redstone comparator update return false; } @Override public boolean canHarvestWithHand() { return false; } }
1,515
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockOreQuartz.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockOreQuartz.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemQuartz; import cn.nukkit.item.ItemTool; import cn.nukkit.item.enchantment.Enchantment; import cn.nukkit.math.NukkitRandom; import java.util.concurrent.ThreadLocalRandom; /** * Created on 2015/12/26 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockOreQuartz extends BlockSolid { public BlockOreQuartz() { } @Override public String getName() { return "Quartz Ore"; } @Override public int getId() { return QUARTZ_ORE; } @Override public double getHardness() { return 3; } @Override public double getResistance() { return 5; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public Item[] getDrops(Item item) { if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) { int count = 1; Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING); if (fortune != null && fortune.getLevel() >= 1) { int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1; if (i < 0) { i = 0; } count = i + 1; } return new Item[]{ new ItemQuartz(0, count) }; } else { return new Item[0]; } } @Override public int getDropExp() { return new NukkitRandom().nextRange(1, 5); } @Override public boolean canHarvestWithHand() { return false; } }
1,681
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockDoorJungle.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockDoorJungle.java
package cn.nukkit.block; import cn.nukkit.item.Item; import cn.nukkit.item.ItemDoorJungle; public class BlockDoorJungle extends BlockDoorWood { public BlockDoorJungle() { this(0); } public BlockDoorJungle(int meta) { super(meta); } @Override public String getName() { return "Jungle Door Block"; } @Override public int getId() { return JUNGLE_DOOR_BLOCK; } @Override public Item toItem() { return new ItemDoorJungle(); } }
522
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsBrick.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsBrick.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * Created on 2015/11/25 by xtypr. * Package cn.nukkit.block in project Nukkit . */ public class BlockStairsBrick extends BlockStairs { public BlockStairsBrick() { this(0); } public BlockStairsBrick(int meta) { super(meta); } @Override public int getId() { return BRICK_STAIRS; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Brick Stairs"; } @Override public BlockColor getColor() { return BlockColor.STONE_BLOCK_COLOR; } @Override public boolean canHarvestWithHand() { return false; } }
943
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockButtonStone.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockButtonStone.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; /** * Created by CreeperFace on 27. 11. 2016. */ public class BlockButtonStone extends BlockButton { public BlockButtonStone() { this(0); } public BlockButtonStone(int meta) { super(meta); } @Override public int getId() { return STONE_BUTTON; } @Override public String getName() { return "Stone Button"; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } }
535
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockPlanks.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockPlanks.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; import cn.nukkit.utils.BlockColor; /** * author: MagicDroidX * Nukkit Project */ public class BlockPlanks extends BlockSolidMeta { public static final int OAK = 0; public static final int SPRUCE = 1; public static final int BIRCH = 2; public static final int JUNGLE = 3; public static final int ACACIA = 4; public static final int DARK_OAK = 5; public BlockPlanks() { this(0); } public BlockPlanks(int meta) { super(meta % 6); } @Override public int getId() { return WOODEN_PLANKS; } @Override public double getHardness() { return 2; } @Override public double getResistance() { return 15; } @Override public int getBurnChance() { return 5; } @Override public int getBurnAbility() { return 20; } @Override public String getName() { String[] names = new String[]{ "Oak Wood Planks", "Spruce Wood Planks", "Birch Wood Planks", "Jungle Wood Planks", "Acacia Wood Planks", "Dark Oak Wood Planks", }; return this.getDamage() < 0 ? "Unknown" : names[this.getDamage() % 6]; } @Override public int getToolType() { return ItemTool.TYPE_AXE; } @Override public BlockColor getColor() { return BlockColor.WOOD_BLOCK_COLOR; } }
1,516
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z
BlockStairsPurpur.java
/FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/block/BlockStairsPurpur.java
package cn.nukkit.block; import cn.nukkit.item.ItemTool; public class BlockStairsPurpur extends BlockStairs { public BlockStairsPurpur() { this(0); } public BlockStairsPurpur(int meta) { super(meta); } @Override public int getId() { return PURPUR_STAIRS; } @Override public double getHardness() { return 1.5; } @Override public double getResistance() { return 30; } @Override public int getToolType() { return ItemTool.TYPE_PICKAXE; } @Override public String getName() { return "Purpur Stairs"; } }
640
Java
.java
Nukkit/Nukkit
821
272
171
2015-05-23T09:51:41Z
2024-03-21T12:28:05Z