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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
package galacticgreg.api;
import net.minecraft.block.Block;
/**
* Mod "Dimension Block Meta Definition" Defines the Block-Meta combination for Blocks that can be replaced by the
* oregen.
*
*/
public class ModDBMDef {
private String _targetBlockName;
private final int _targetMeta;
private final boolean _canAlwaysReplace;
public String getBlockName() {
return _targetBlockName;
}
public int getMeta() {
return _targetMeta;
}
public boolean getCanAlwaysReplace() {
return _canAlwaysReplace;
}
/**
* Internal function
* <p>
* Check if the given Block is equal to the block in this instance
*
* @param pBlock the Block in question
* @return
*/
public Enums.ReplaceState blockEquals(Block pBlock) {
if (pBlock == null) return Enums.ReplaceState.Unknown;
if (Block.blockRegistry.getNameForObject(pBlock)
.equals(_targetBlockName)) return Enums.ReplaceState.CanReplace;
else return Enums.ReplaceState.CannotReplace;
}
/**
* Internal function
* <p>
* Check if the given Block is equal to the block in this instance and matches the metadata
*
* @param pBlock the block in question
* @param pMeta the metadata in question
* @return
*/
public Enums.ReplaceState blockEquals(Block pBlock, int pMeta) {
Enums.ReplaceState tFlag = Enums.ReplaceState.Unknown;
if (blockEquals(pBlock) == Enums.ReplaceState.CanReplace) {
if (pMeta == _targetMeta || _canAlwaysReplace) tFlag = Enums.ReplaceState.CanReplace;
else tFlag = Enums.ReplaceState.CannotReplace;
}
return tFlag;
}
@Override
public boolean equals(Object other) {
if (other == null) return false;
if (other == this) return true;
if (!(other instanceof ModDBMDef otherModDBMDef)) return false;
return (otherModDBMDef._targetBlockName.equals(_targetBlockName) && otherModDBMDef._targetMeta == _targetMeta);
}
/**
* Create a new "Block that can be replaced by ores" definition. Meta defaults to 0 here
*
* @param pTargetBlockName The unlocalizedName of the block
*/
public ModDBMDef(String pTargetBlockName) {
this(pTargetBlockName, 0, false);
}
/**
* Create a new "Block that can be replaced by ores" definition
*
* @param pTargetBlockName The unlocalizedName of the block
* @param pMetaData The blocks metadata
*/
public ModDBMDef(String pTargetBlockName, int pMetaData) {
this(pTargetBlockName, pMetaData, false);
}
/**
* Create a new "Block that can be replaced by ores" definition
*
* @param pTargetBlock The instance of the block that can be replaced
* @param pMetaData The blocks metadata
*/
public ModDBMDef(Block pTargetBlock, int pMetaData) {
this(Block.blockRegistry.getNameForObject(pTargetBlock), pMetaData, false);
}
/**
* Create a new "Block that can be replaced by ores" definition. Meta defaults to 0 here
*
* @param pTargetBlock The instance of the block that can be replaced
*/
public ModDBMDef(Block pTargetBlock) {
this(Block.blockRegistry.getNameForObject(pTargetBlock), 0, false);
}
/**
* Create a new "Block that can be replaced by ores" definition
*
* @param pTargetBlock
* @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
* [block]:*
*/
public ModDBMDef(Block pTargetBlock, boolean pCanAlwaysReplace) {
this(Block.blockRegistry.getNameForObject(pTargetBlock), -1, pCanAlwaysReplace);
}
/**
* Create a new "Block that can be replaced by ores" definition
*
* @param pTargetBlockName The unlocalizedName of the block
* @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
* [block]:*
*/
public ModDBMDef(String pTargetBlockName, boolean pCanAlwaysReplace) {
this(pTargetBlockName, -1, false);
}
/**
* Create a new "Block that can be replaced by ores" definition
*
* @param pTargetBlockName The unlocalizedName of the block
* @param pMetaData The blocks metadata
* @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
* [block]:*
*/
public ModDBMDef(String pTargetBlockName, int pMetaData, boolean pCanAlwaysReplace) {
_targetBlockName = pTargetBlockName;
_targetMeta = pMetaData;
_canAlwaysReplace = pCanAlwaysReplace;
}
/**
* Internal function Never run this function. It is used to update the blocks name when GalacticGreg is initializing
* its internal structures
*
* @param pParentModName The modname to be attached to the block-name
*/
public void updateBlockName(String pParentModName) {
// Do we already have a FQBN? then do nothing
if (_targetBlockName.contains(":")) {
return;
}
_targetBlockName = String.format("%s:%s", pParentModName, _targetBlockName);
}
}
|