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 vote down vote up
@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: LibParticles.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #3
Source File: ItemEnderPart.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: BlockWalrus.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@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 #5
Source File: GTTileCharcoalPit.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 6 votes vote down vote up
@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 #7
Source File: QCraftProxyCommon.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #9
Source File: ContainerLifecycleCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: ArtifactServerEventHandler.java    From Artifacts with MIT License 6 votes vote down vote up
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 #11
Source File: ItemPlasticPlants.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@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 #12
Source File: BuildContainerCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
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 #13
Source File: BlockStoneMachine.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #14
Source File: ItemRuler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #15
Source File: PositionUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the given position scaled by the given scale factors, and clamped to within the world border
 * of the destination world, with the given margin to the border.
 */
public static Vec3d getScaledClampedPosition(Vec3d pos, @Nullable World world, double scaleX, double scaleY, double scaleZ, int margin)
{
    // The world border in other dimensions than the Overworld gets always
    // reset to the default 60M blocks when the dimensions loads.
    // The client side WorldBorder is synced on world load, so the
    // border _appears_ to be where the Overworld border is,
    // but on the server side the border is actually at 60M blocks,
    // unless the border has been changed using the commands,
    // because the border change listener will then update the border
    // size from the Overworld border to the other dimensions (see WorldServerMulti),
    // however that change only persists as long as the dimension stays loaded.

    // So we are just getting the border size from the Overworld for now...
    world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);

    int worldLimit = 30000000 - margin;
    // Note: getActualHeight() could be better (at least for the Nether), but it would return 128 for the End too...
    int worldHeight = world != null ? world.getHeight() : 256;
    double posX = MathHelper.clamp(pos.x * scaleX, -worldLimit, worldLimit);
    double posY = MathHelper.clamp(pos.y * scaleY, 0, worldHeight);
    double posZ = MathHelper.clamp(pos.z * scaleZ, -worldLimit, worldLimit);

    if (world != null)
    {
        WorldBorder border = world.getWorldBorder();
        margin = Math.min(margin, (int)(border.getDiameter() / 2));

        posX = MathHelper.clamp(pos.x * scaleX, border.minX() + margin, border.maxX() - margin);
        posZ = MathHelper.clamp(pos.z * scaleZ, border.minZ() + margin, border.maxZ() - margin);
        //System.out.printf("border size: %.2f posX: %.4f posY: %.4f posZ: %.4f\n", border.getDiameter(), posX, posY, posZ);
        //System.out.printf("border: %s (%s)\n", border.getClass().getName(), border);
    }

    return new Vec3d(posX, posY, posZ);
}
 
Example #16
Source File: BlockWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static ActionResult statisOnUse(org.sandboxpowered.sandbox.api.state.BlockState blockState_1, org.sandboxpowered.sandbox.api.world.World world_1, Position blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1, Block block) {
    InteractionResult result = block.onBlockUsed(
            world_1,
            blockPos_1,
            blockState_1,
            playerEntity_1,
            hand_1 == Hand.MAIN_HAND ? org.sandboxpowered.sandbox.api.entity.player.Hand.MAIN_HAND : org.sandboxpowered.sandbox.api.entity.player.Hand.OFF_HAND,
            WrappingUtil.convert(blockHitResult_1.getSide()),
            (Vec3f) (Object) new Vector3f(blockHitResult_1.getPos())
    );
    return WrappingUtil.convert(result);
}
 
Example #17
Source File: ItemPotteryJug.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
	ItemStack itemstack = playerIn.getHeldItem(handIn);
	if(IsWaterJug(itemstack))
	{
		playerIn.setActiveHand(handIn);
		return new ActionResult(EnumActionResult.SUCCESS, itemstack);
	}
	return super.onItemRightClick(worldIn, playerIn, handIn);
}
 
Example #18
Source File: ItemQuantumWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@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 #19
Source File: Rituals.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
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 #20
Source File: GTBlockBaseMachine.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #21
Source File: BlockSelector.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@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 #22
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 5 votes vote down vote up
private void queueRetrogen(String retro, World world, ChunkPos chunkCoords)
{
    if (world instanceof WorldServer)
    {
        ListMultimap<ChunkPos, String> currentWork = pendingWork.get(world);
        if (currentWork == null)
        {
            currentWork = ArrayListMultimap.create();
            pendingWork.put(world, currentWork);
        }

        currentWork.put(chunkCoords, retro);
    }
}
 
Example #23
Source File: WorldTickHandler.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@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 #24
Source File: WandTriggerRegistry.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
 * 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 #25
Source File: ProfileVillager.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@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 #26
Source File: BlockCrop.java    From AgriCraft with MIT License 5 votes vote down vote up
@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 #27
Source File: ClassroomDecoratorImplementation.java    From malmo with MIT License 5 votes vote down vote up
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 #28
Source File: BlockCertusTank.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@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());
	}
}
 
Example #29
Source File: NEIServerUtils.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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: TinyPumpkinBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@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);
	}
}