Java Code Examples for net.minecraft.world.World.setData()

The following are Jave code examples for showing how to use setData() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: WirelessRedstone   File: ItemEmptyWirelessMap.java   View Source Code Vote up 5 votes
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    ItemStack itemstack1 = new ItemStack(ModItems.itemWirelessMap, 1, worldIn.getUniqueDataId("map"));
    String s = "map_" + itemstack1.getItemDamage();
    MapData mapdata = new MapData(s);
    worldIn.setData(s, mapdata);
    mapdata.scale = 0;
    int i = 128 * (1 << mapdata.scale);
    mapdata.xCenter = (int)(Math.round(playerIn.posX / (double)i) * (long)i);
    mapdata.zCenter = (int)(Math.round(playerIn.posZ / (double)i) * (long)i);
    mapdata.dimension = worldIn.provider.getDimension();
    mapdata.markDirty();
    itemStackIn.shrink(1);

    if (itemStackIn.getCount() <= 0)
    {
        return new ActionResult<>(EnumActionResult.SUCCESS, itemstack1);
    }
    else
    {
        if (!playerIn.inventory.addItemStackToInventory(itemstack1.copy()))
        {
            playerIn.dropItem(itemstack1, false);
        }

        return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
    }
}
 
Example 2
Project: MeeCreeps   File: ServerActionManager.java   View Source Code Vote up 4 votes
public void save() {
    World world = DimensionManager.getWorld(0);
    world.setData(NAME, this);
    markDirty();
}