Posted October 30, 20177 yr 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.