summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/item/ItemBookmark.java
blob: a51aec9fd23c4cfa34e4180fdf642a3bd797f14c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package jp.plusplus.fbs.item;

import jp.plusplus.fbs.FBS;
import jp.plusplus.fbs.block.BlockCore;
import jp.plusplus.fbs.world.structure.MapGenSealdLib;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.gen.structure.MapGenStructureIO;

import java.util.List;

/**
 * Created by pluslus_F on 2015/06/23.
 */
public class ItemBookmark extends ItemBase {
    public ItemBookmark() {
        setUnlocalizedName("bookmark");
        setTextureName("bookmark");
        setMaxDamage(64);
        setMaxStackSize(1);
    }

    @Override
    public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player){
        if(!world.isRemote){
            /*
            まー言いたい事はいろいろあるけどさ、
            なんでfindClosestStructureが実質Stronghold限定の実装なのよ。
            わざわざ引数に構造物名とっといてさ。

            @もやん
                fニヽ
                |_||
                |= |
                | |
                |= |
               i⌒| |⌒i_
              /| | | | ヽ
             | ( ( ( ( |
             |/      |
             |       |
              \      ノ
               \    /
               |   |
            */
            item.damageItem(1, player);

            int x=MathHelper.floor_double(player.posX), z=MathHelper.floor_double(player.posZ);
            int dx=(x/16)-1, dz=(z/16);

            //FBS.logger.info("at:"+dx+","+dz);

            //強硬手段
            for(int i=10;i<50;i++){
                if(world.getBlock(x, i, z)== BlockCore.plank){
                    player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.shining"));
                    break;
                }
            }

            if(MapGenSealdLib.isLibraryChunk(world, dx, dz)){
                player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.success"));
            }
            else{
                boolean found=false;
                for(int i=0;i<3 && !found;i++){
                    for(int k=0;k<3 && !found;k++){
                        if(MapGenSealdLib.isLibraryChunk(world, dx+(i-1), dz+(k-1))){
                            found=true;
                        }
                    }
                }
                if(found){
                    player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.found"));
                }
                else{
                    player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.failure"));
                }
            }
        }


        return item;
    }

    /*
    @Override
    public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
        if(world.isRemote) return true;

        item.damageItem(1, player);

        world.findClosestStructure("Sealed Library", )

        if(world.provider.dimensionCrackId!=0){
            player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.failure"));
            return true;
        }

        int dx=(x/16)-1, dz=(z/16);

        if(MapGenSealdLib.isLibraryChunk(world, dx, dz)){
            player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.success"));
        }
        else{
            boolean found=false;
            for(int i=0;i<3 && !found;i++){
                for(int k=0;k<3 && !found;k++){
                    if(MapGenSealdLib.isLibraryChunk(world, dx+(i-1), dz+(k-1))){
                        found=true;
                    }
                }
            }
            if(found){
                player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.found"));
            }
            else{
                player.addChatComponentMessage(new ChatComponentTranslation("info.fbs.bookmark.failure"));
            }
        }

        return true;
    }
    */

    @Override
    public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) {
        p_77624_3_.add(StatCollector.translateToLocal("info.fbs.bookmark.0"));
    }
}