net.minecraft.world.World Java Examples
The following examples show how to use
net.minecraft.world.World.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DispenserBehaviorFireChargeMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 7 votes |
@SuppressWarnings("UnresolvedMixinReference") @Inject(method = "dispenseSilently(Lnet/minecraft/util/math/BlockPointer;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"), cancellable = true) private void convertNetherrack(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) { if (!CarpetExtraSettings.fireChargeConvertsToNetherrack) return; World world = pointer.getWorld(); Direction direction = pointer.getBlockState().get(DispenserBlock.FACING); BlockPos front = pointer.getBlockPos().offset(direction); BlockState state = world.getBlockState(front); if (state.getBlock() == Blocks.COBBLESTONE) { world.setBlockState(front, Blocks.NETHERRACK.getDefaultState()); stack.decrement(1); cir.setReturnValue(stack); cir.cancel(); } }
Example #2
Source File: BlockStoneMachine.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int metadata = world.getBlockMetadata(x, y, z); if (metadata == 0 || metadata == 3) { if (world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { return world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, player, side, hitX, hitY, hitZ); } } else if (metadata == 1) { if(world.isAirBlock(x, y + 1, z)) { return ConfigBlocks.blockStoneDevice.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); } return true; } else if(metadata == 4) { player.openGui(Gadomancy.instance, 2, world, x, y, z); return true; } return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); }
Example #3
Source File: BlockWalrus.java From ExtraCells1 with MIT License | 6 votes |
@Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } }
Example #4
Source File: BuildContainerCommands.java From mobycraft with Apache License 2.0 | 6 votes |
private List<BoxContainer> containerColumn(List<Container> containers, int index, BlockPos pos, World world) { List<BoxContainer> boxContainers = new ArrayList<BoxContainer>(); int endIndex = 10; if (containers.size() - (index * 10) < 10) { endIndex = containers.size() - index * 10; } for (int i = index * 10; i < (index * 10) + endIndex; i++) { Container container = containers.get(i); boxContainers.add(new BoxContainer(pos, container.getId(), container.getNames()[0], container.getImage(), world)); pos = pos.add(0, 6, 0); } return boxContainers; }
Example #5
Source File: ItemPlasticPlants.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){ BlockPneumaticPlantBase plant = (BlockPneumaticPlantBase)getPlantBlockIDFromSeed(stack.getItemDamage()); if(side != (plant.isPlantHanging() ? 0 : 1)) { return false; } else if(player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + (plant.isPlantHanging() ? -1 : 1), z, side, stack)) { if(plant.canBlockStay(world, x, y + (plant.isPlantHanging() ? -1 : 1), z) && world.isAirBlock(x, y + (plant.isPlantHanging() ? -1 : 1), z)) { world.setBlock(x, y + (plant.isPlantHanging() ? -1 : 1), z, plant, 7, 3); --stack.stackSize; return true; } else { return false; } } else { return false; } }
Example #6
Source File: ArtifactServerEventHandler.java From Artifacts with MIT License | 6 votes |
private boolean blockUnderAntibuilderInfluence(World world, int x, int y, int z) { if(world.getBlock(x, y, z) == Blocks.fire || world.getBlock(x, y, z) == BlockAntibuilder.instance || world.getBlock(x, y, z) == Blocks.web || world.getBlock(x, y, z) == Blocks.torch || world.getBlock(x, y, z) == BlockSword.instance) { return false; } for(AntibuilderLocation al : TileEntityAntibuilder.antibuilders.keySet()) { if(world.provider.dimensionId == al.dimension && MathHelper.abs(x - al.x) <= 5 && MathHelper.abs(y - al.y) <= 5 && MathHelper.abs(z - al.z) <= 5) { return true; } } return false; }
Example #7
Source File: ContainerLifecycleCommands.java From mobycraft with Apache License 2.0 | 6 votes |
public void killChaosMonkeys() { World world = sender.getEntityWorld(); int numberOfMonkeys = 0; for (Entity entity : world.getLoadedEntityList()) { if (entity instanceof EntityChaosMonkey) { entity.setDead(); numberOfMonkeys++; } } if (numberOfMonkeys == 0) { sendErrorMessage("There are no Chaos Monkeys in this world!"); } else if (numberOfMonkeys == 1) { sendConfirmMessage("Killed 1 Chaos Monkey."); } else { sendConfirmMessage("Killed " + numberOfMonkeys + " Chaos Monkeys."); } }
Example #8
Source File: ItemEnderPart.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return EnumActionResult.PASS; } ItemStack stack = player.getHeldItem(hand); // Ender Relic if (stack.getMetadata() == 40 && EntityUtils.spawnEnderCrystal(world, pos)) { if (player.capabilities.isCreativeMode == false) { stack.shrink(1); } return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example #9
Source File: LibParticles.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static void FIZZING_ITEM(World world, Vec3d pos) { ParticleBuilder fizz = new ParticleBuilder(10); fizz.setScale(0.3f); fizz.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED)); fizz.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f)); ParticleSpawner.spawn(fizz, world, new StaticInterp<>(pos.add(0, 0.5, 0)), 10, 0, (aFloat, particleBuilder) -> { fizz.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255))); fizz.setLifetime(RandUtil.nextInt(20, 30)); fizz.setPositionOffset(new Vec3d( RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1) )); fizz.setMotion(new Vec3d(RandUtil.nextDouble(-0.005, 0.005), RandUtil.nextDouble(0.04, 0.08), RandUtil.nextDouble(-0.005, 0.005))); }); }
Example #10
Source File: GTTileCharcoalPit.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (this.isActive) { if (rand.nextInt(16) == 0) { worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); } for (int i = 0; i < 3; ++i) { double d0 = (double) pos.getX() + rand.nextDouble(); double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D; double d2 = (double) pos.getZ() + rand.nextDouble(); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D); } } }
Example #11
Source File: BlockGardenProxy.java From GardenCollection with MIT License | 6 votes |
@Override public void randomDisplayTick (World world, int x, int y, int z, Random random) { TileEntityGarden te = getGardenEntity(world, x, y, z); BlockGarden garden = getGardenBlock(world, x, y, z); if (te == null || garden == null) return; for (int slot : garden.getSlotProfile().getPlantSlots()) { Block block = getPlantBlock(te, slot); if (block == null) continue; bindSlot(world, x, y, z, te, slot); try { block.randomDisplayTick(world, x, y, z, random); } catch (Exception e) { continue; } finally { unbindSlot(world, x, y, z, te); } } }
Example #12
Source File: QCraftProxyCommon.java From qcraft-mod with Apache License 2.0 | 6 votes |
@Override public Object getClientGuiElement( int id, EntityPlayer player, World world, int x, int y, int z ) { TileEntity tile = world.getTileEntity( x, y, z ); switch( id ) { case QCraft.quantumComputerGUIID: { if( tile != null && tile instanceof TileEntityQuantumComputer ) { TileEntityQuantumComputer drive = (TileEntityQuantumComputer) tile; return getQuantumComputerGUI( player.inventory, drive ); } break; } } return null; }
Example #13
Source File: ItemRuler.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return EnumActionResult.SUCCESS; } // Hack to work around the fact that when the NBT changes, the left click event will fire again the next tick, // so it would easily result in the state toggling multiple times per left click Long last = this.lastLeftClick.get(player.getUniqueID()); if (last == null || (world.getTotalWorldTime() - last) >= 6) { // When not sneaking, adjust the position to be the adjacent block and not the targeted block itself this.setOrRemovePosition(player.getHeldItem(hand), new BlockPosEU(pos, player.getEntityWorld().provider.getDimension(), side), POS_END, player.isSneaking() == false); } this.lastLeftClick.put(player.getUniqueID(), world.getTotalWorldTime()); return EnumActionResult.SUCCESS; }
Example #14
Source File: FWBlock.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
@Override @SuppressWarnings({"unchecked", "rawtypes"}) public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) { Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z)); blockInstance.components.getOp(Collider.class).ifPresent( collider -> { Set<Cuboid> boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? EntityConverter.instance().toNova(entity) : null)); list.addAll( boxes .stream() .map(c -> c.add(new Vector3D(x, y, z))) .filter(c -> c.intersects(CuboidConverter.instance().toNova(aabb))) .map(CuboidConverter.instance()::toNative) .collect(Collectors.toList()) ); } ); }
Example #15
Source File: MoCEntityCrab.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public MoCEntityCrab(World world) { super(world); setSize(0.3F, 0.3F); health = 6; setEdad(50 + rand.nextInt(50)); }
Example #16
Source File: BlockSelector.java From OpenPeripheral-Addons with MIT License | 5 votes |
@Override public boolean onSelected(World world, int x, int y, int z, DrawBlockHighlightEvent evt) { final TileEntitySelector selector = getTileEntity(world, x, y, z, TileEntitySelector.class); if (selector != null) { final MovingObjectPosition mop = evt.target; this.selectorAABB = selector.getSelection(mop.hitVec, mop.sideHit); } else this.selectorAABB = null; return false; }
Example #17
Source File: GTBlockBaseMachine.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { if (tooltipSize == 0) { return; } for (int i = 0; i < this.tooltipSize; i++) { tooltip.add(I18n.format(this.getUnlocalizedName().replace("tile", "tooltip") + i)); } }
Example #18
Source File: Rituals.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID) { for (int i = 1; i <= 4; i++) { if (Rituals.checkDirectionOfRitualValid(world, x, y, z, ritualID, i)) { return i; } } return -1; }
Example #19
Source File: ShipCore.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ShipCoreTE ste = (ShipCoreTE) worldIn.getTileEntity(pos); if (!worldIn.isRemote && ste.toConstruct.isEmpty()) { ste.startSearch(playerIn); }else if(!worldIn.isRemote) { ste.construct(); } return true; }
Example #20
Source File: ItemQuantumWing.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { if (world.isRemote) { boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed(); boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed(); boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed(); if (isJumping) player.motionY = 0.85; if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode) player.motionY *= 0.3; if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.1; if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode) player.motionY = -0.05; if (isSneaking && isHoldingJump) player.motionY = 0; if (isSneaking && !player.onGround && !isHoldingJump) player.motionY = -0.6; } if (player.fallDistance > 0.0F) player.fallDistance = 0; }
Example #21
Source File: WorldTickHandler.java From EmergingTechnology with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.WorldTickEvent event) { if (event.side != Side.SERVER) { return; } if (event.phase == TickEvent.Phase.END) { World world = event.world; int dim = world.provider.getDimension(); ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim); if (chunks != null && !chunks.isEmpty()) { ChunkPos c = chunks.pollFirst(); long worldSeed = world.getSeed(); Random rand = new Random(worldSeed); long xSeed = rand.nextLong() >> 2 + 1L; long zSeed = rand.nextLong() >> 2 + 1L; rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed); OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false); chunksToGen.put(dim, chunks); } else if (chunks != null) { chunksToGen.remove(dim); } } }
Example #22
Source File: DimensionManager.java From AdvancedRocketry with MIT License | 5 votes |
public static DimensionProperties getEffectiveDimId(World world, BlockPos pos) { int dimId = world.provider.getDimension(); if(dimId == Configuration.spaceDimId) { ISpaceObject obj = SpaceObjectManager.getSpaceManager().getSpaceStationFromBlockCoords(pos); if(obj != null) return (DimensionProperties) obj.getProperties().getParentProperties(); else return defaultSpaceDimensionProperties; } else return getInstance().getDimensionProperties(dimId); }
Example #23
Source File: WandTriggerRegistry.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
/** * modid sensitive version */ public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, Block block, int meta, String modid) { if (!triggers.containsKey(modid)) return false; HashMap<List,List> temp = triggers.get(modid); List l = temp.get(Arrays.asList(block,meta)); if (l==null) l = temp.get(Arrays.asList(block,-1)); if (l==null) return false; IWandTriggerManager manager = (IWandTriggerManager) l.get(0); int event = (Integer) l.get(1); return manager.performTrigger(world, wand, player, x, y, z, side, event); }
Example #24
Source File: ProfileVillager.java From minecraft-roguelike with GNU General Public License v3.0 | 5 votes |
@Override public void addEquipment(World world, Random rand, int level, IEntity mob) { mob.setMobClass(MobType.ZOMBIEVILLAGER, false); ItemStack weapon = ItemTool.getRandom(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level)); mob.setSlot(EntityEquipmentSlot.MAINHAND, weapon); mob.setSlot(EntityEquipmentSlot.OFFHAND, Shield.get(rand)); MonsterProfile.get(MonsterProfile.TALLMOB).addEquipment(world, rand, level, mob); }
Example #25
Source File: BlockTataraSmelting.java From Sakura_mod with MIT License | 5 votes |
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand){ super.updateTick(worldIn, pos, state, rand); if (!worldIn.isAreaLoaded(pos, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light int i = this.getTime(state); setSmelting(worldIn, pos); if (i < this.getFinishTime()){ if(rand.nextInt(1) == 0){ worldIn.setBlockState(pos, this.withTime(i + 1), 2); } } }
Example #26
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public void onBlockRemoved(BlockState state1, World world, BlockPos pos, BlockState state2, boolean flag) { if (state1.getBlock() != state2.getBlock()) { BlockEntity be = world.getBlockEntity(pos); if (be instanceof TinyPumpkinBlockEntity) { ItemScatterer.spawn(world, pos, ((TinyPumpkinBlockEntity) be).getAllItems()); world.updateHorizontalAdjacent(pos, this); } super.onBlockRemoved(state1, world, pos, state2, flag); } }
Example #27
Source File: BlockCrop.java From AgriCraft with MIT License | 5 votes |
@Override @net.minecraftforge.fml.common.Optional.Method(modid = "botania") public void harvestByHorn(World world, BlockPos pos, ItemStack stack, EnumHornType eht) { if (eht == EnumHornType.WILD) { WorldHelper.getTile(world, pos, TileEntityCrop.class) .filter(TileEntityCrop::isMature) .ifPresent(crop -> { crop.onHarvest((product) -> WorldHelper.spawnItemInWorld(world, pos, product), null); }); } }
Example #28
Source File: ClassroomDecoratorImplementation.java From malmo with MIT License | 5 votes |
private void drawPuzzle(World world, Random rand, Palette palette) { int doorLocation = this.left + rand.nextInt(this.right - this.left - 4) + 2; for(int x=this.left; x<this.right; x++){ for(int y=this.bottom; y<this.top; y++){ setBlockState(world, new BlockPos(x,y,this.z), palette.wall); } if((x - this.left - 1) % 2 == 0 && x < this.right - 1){ setBlockState(world, new BlockPos(x, this.bottom + ROOM_HEIGHT - 1, this.z - 1), palette.light, null, Facing.NORTH, null); setBlockState(world, new BlockPos(x, this.bottom + ROOM_HEIGHT - 1, this.z + 1), palette.light, null, Facing.SOUTH, null); } } Facing facing = this.getIn() == this.north ? Facing.NORTH : Facing.SOUTH; setBlockState(world, new BlockPos(doorLocation, this.bottom, this.z), palette.puzzleDoorLower, null, facing, null); setBlockState(world, new BlockPos(doorLocation, this.bottom + 1, this.z), palette.puzzleDoorUpper, null, facing, null); if(this.hint){ setBlockState(world, new BlockPos(doorLocation, this.bottom - 1, this.z), palette.hint); } Room room = getIn(); int triggerX; if(rand.nextDouble() < 0.5){ triggerX = doorLocation - 1; }else{ triggerX = doorLocation + 1; } if(room == this.north){ setBlockState(world, new BlockPos(triggerX, this.bottom + 1, this.z - 1), palette.trigger, null, Facing.NORTH, null); }else{ setBlockState(world, new BlockPos(triggerX, this.bottom + 1, this.z + 1), palette.trigger, null, Facing.SOUTH, null); } }
Example #29
Source File: NEIServerUtils.java From NotEnoughItems with MIT License | 5 votes |
public static void setHourForward(World world, int hour, boolean notify) { long day = (getTime(world) / 24000L) * 24000L; long newTime = day + 24000L + hour * 1000; setTime(newTime, world); if (notify) ServerUtils.sendChatToAll(new ChatComponentTranslation("nei.chat.time", getTime(world) / 24000L, hour)); }
Example #30
Source File: BlockCertusTank.java From ExtraCells1 with MIT License | 5 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID) { if (!world.isRemote) { PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket()); } }