Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I remember an old 1.6.4 mod called ChristmasCraft, made by newthead and once updated to 1.7.10 by Zuxelas.  The stocking block included in the mod changes to have a present in it when the player sleeps, and the present could be retrieved by a right-click.

 

How can I transfer this code into a 1.12.2 version?

 

Here's the code used in the mod's 1.7.10 version:

@SubscribeEvent
	public void onWorldTick(WorldTickEvent event)
	{
		if (event.phase == Phase.START)
		{
			if (!ChristmasCraft.isChristmasTime())
			{
				return;
			}
			boolean isChristmasDay = ChristmasCraft.isChristmasDay();
			WorldServer world = (WorldServer)event.world;
			if (world.areAllPlayersAsleep())
			{
				Object[] tiles = world.loadedTileEntityList.toArray();
				for (int i = 0; i < tiles.length; i++)
				{
					TileEntity tile = (TileEntity)tiles[i];
					Block block = world.getBlock(tile.xCoord, tile.yCoord, tile.zCoord);
					if (block == ChristmasCraft.blockStocking)
					{
						ItemStack present = ChristmasCraft.getRandomStockingGift();
						if (((TileEntityStocking)tile).getContents() == null)
						{
							((TileEntityStocking)tile).setContents(present);
						}
					}
					if (isChristmasDay && block == ChristmasCraft.blockTreestand)
					{
						generatePresentsAroundTree(world, tile.xCoord, tile.yCoord, tile.zCoord);
					}
				}
			}
		}
	}

 

BlockStocking:

@Override
	public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int side, float f1, float f2, float f3)
	{
		ItemStack contents = null;
		TileEntityStocking tile = (TileEntityStocking)world.getTileEntity(i, j, k);
		if (tile != null && tile.getContents() != null)
		{
			contents = tile.getContents();
		}
		if (entityplayer.getCurrentEquippedItem() != null && contents == null)
		{
			ItemStack heldItem = entityplayer.getCurrentEquippedItem();
			if (Block.getBlockFromItem(heldItem.getItem()) == ChristmasCraft.blockPresent)
			{
				ItemStack newContents = heldItem.copy();
				newContents.stackSize = 1;
				tile.setContents(newContents);
				heldItem.stackSize -= 1;
				return true;
			}
		}
		else
		{
			dropStockingContents(world, i, j, k);
			return true;
		}
		return false;
	}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.