@Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { BlockStateDelegate blockStateDelegate = new BlockStateDelegate(); if (GlowTree.newInstance(type, ThreadLocalRandom.current(), blockStateDelegate) .generate(loc)) { List<BlockState> blockStates = new ArrayList<>(blockStateDelegate.getBlockStates()); StructureGrowEvent growEvent = new StructureGrowEvent(loc, type, false, null, blockStates); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { for (BlockState state : blockStates) { state.update(true); if (delegate != null) { delegate.setTypeIdAndData(state.getX(), state.getY(), state.getZ(), state .getTypeId(), state.getRawData()); } } return true; } } return false; }
@Override public int getZ() { return base.getZ(); }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onStructureGrow(StructureGrowEvent event) { Location loc = event.getLocation(); String wname = getWorld(loc.getWorld()).getName(); int minx, maxx, miny, maxy, minz, maxz; minx = maxx = loc.getBlockX(); miny = maxy = loc.getBlockY(); minz = maxz = loc.getBlockZ(); /* Calculate volume impacted by explosion */ List<BlockState> blocks = event.getBlocks(); for(BlockState b: blocks) { int x = b.getX(); if(x < minx) minx = x; if(x > maxx) maxx = x; int y = b.getY(); if(y < miny) miny = y; if(y > maxy) maxy = y; int z = b.getZ(); if(z < minz) minz = z; if(z > maxz) maxz = z; } sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz); if(onstructuregrow) { mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "structuregrow"); } } };
public static void setTileEntityNBTTagCompound(BlockState tile, Object comp) { try { Object pos = getNewBlockPosition(tile.getX(), tile.getY(), tile.getZ()); Object cworld = getCraftWorld().cast(tile.getWorld()); Object nmsworld = cworld.getClass().getMethod("getHandle").invoke(cworld); Object o = nmsworld.getClass().getMethod("getTileEntity", pos.getClass()).invoke(nmsworld, pos); Method method = getTileEntity().getMethod("a", getNBTTagCompound()); method.invoke(o, comp); } catch (Exception e) { e.printStackTrace(); } }
public static Object getTileEntityNBTTagCompound(BlockState tile) { try { Object pos = getNewBlockPosition(tile.getX(), tile.getY(), tile.getZ()); Object cworld = getCraftWorld().cast(tile.getWorld()); Object nmsworld = cworld.getClass().getMethod("getHandle").invoke(cworld); Object o = nmsworld.getClass().getMethod("getTileEntity", pos.getClass()).invoke(nmsworld, pos); Method method = getTileEntity().getMethod(MethodNames.getTileDataMethodName(), getNBTTagCompound()); Object tag = getNBTTagCompound().newInstance(); Object answer = method.invoke(o, tag); return answer != null ? answer:tag; } catch (Exception e) { e.printStackTrace(); } return null; }
@Override public synchronized boolean isTrue(BlockState blockState) { if (blockState == null) { return false; } return isTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); }
@Override public void setTrue(BlockState blockState) { if (blockState == null) { return; } setTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); }
@Override public synchronized void setFalse(BlockState blockState) { if (blockState == null) { return; } setFalse(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld()); }
public static void setTileEntityNBTTagCompound(BlockState tile, Object comp) { try { Object pos = ObjectCreator.NMS_BLOCKPOSITION.getInstance(tile.getX(), tile.getY(), tile.getZ()); Object cworld = ClassWrapper.CRAFT_WORLD.getClazz().cast(tile.getWorld()); Object nmsworld = ReflectionMethod.CRAFT_WORLD_GET_HANDLE.run(cworld); Object o = ReflectionMethod.NMS_WORLD_GET_TILEENTITY.run(nmsworld, pos); ReflectionMethod.TILEENTITY_SET_NBT.run(o, comp); } catch (Exception e) { e.printStackTrace(); } }
public RepairableBlock(BlockState state) { this.state = state; world = state.getWorld(); x = state.getX(); y = state.getY(); z = state.getZ(); data = state.getBlockData(); type = state.getType(); }
public static Object getTileEntityNBTTagCompound(BlockState tile) { try { Object pos = ObjectCreator.NMS_BLOCKPOSITION.getInstance(tile.getX(), tile.getY(), tile.getZ()); Object cworld = ClassWrapper.CRAFT_WORLD.getClazz().cast(tile.getWorld()); Object nmsworld = ReflectionMethod.CRAFT_WORLD_GET_HANDLE.run(cworld); Object o = ReflectionMethod.NMS_WORLD_GET_TILEENTITY.run(nmsworld, pos); Object tag = ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz().newInstance(); Object answer = ReflectionMethod.TILEENTITY_GET_NBT.run(o, tag); if (answer == null) answer = tag; return answer; } catch (Exception e) { e.printStackTrace(); } return null; }
/** * @param state */ public GriefBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
/** * @param state */ public TranslocationBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
public RepairableDoor(BlockState state) { super(state); other = state.getBlock().getRelative(BlockFace.UP).getState(); BlockState attached = state.getBlock().getRelative(BlockFace.DOWN).getState(); x = attached.getX(); y = attached.getY(); z = attached.getZ(); }
ret += "x:" + state.getX() + ";"; ret += "y:" + state.getY() + ";"; ret += "z:" + state.getZ() + ";"; ret += "world:" + state.getWorld().getName(); if(items != null){
public RepairableAttachable(BlockState state) { super(state); BlockState attached; if (state.getData() instanceof Attachable) attached = state.getBlock().getRelative(((Attachable) state.getData()).getAttachedFace()).getState(); else attached = state.getBlock().getRelative(BlockFace.DOWN).getState(); x = attached.getX(); y = attached.getY(); z = attached.getZ(); state.getBlock().setType(Material.STONE); }