/
ModBlocks.java
245 lines (203 loc) · 9.13 KB
/
ModBlocks.java
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package choonster.testmod3.init;
import choonster.testmod3.TestMod3;
import choonster.testmod3.block.*;
import choonster.testmod3.block.pipe.BlockPipeBasic;
import choonster.testmod3.block.pipe.BlockPipeFluid;
import choonster.testmod3.item.block.ItemFluidTank;
import choonster.testmod3.tileentity.*;
import choonster.testmod3.util.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemCloth;
import net.minecraft.item.ItemMultiTexture;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import net.minecraftforge.fml.common.registry.IForgeRegistry;
import java.util.HashSet;
import java.util.Set;
@SuppressWarnings("WeakerAccess")
@ObjectHolder(TestMod3.MODID)
public class ModBlocks {
@ObjectHolder("water_grass")
public static final BlockWaterGrass WATER_GRASS = new BlockWaterGrass();
@ObjectHolder("large_collision_test")
public static final BlockLargeCollisionTest LARGE_COLLISION_TEST = new BlockLargeCollisionTest();
@ObjectHolder("right_click_test")
public static final BlockRightClickTest RIGHT_CLICK_TEST = new BlockRightClickTest();
@ObjectHolder("client_player_right_click")
public static final BlockClientPlayerRightClick CLIENT_PLAYER_RIGHT_CLICK = new BlockClientPlayerRightClick();
@ObjectHolder("rotatable_lamp")
public static final BlockRotatableLamp ROTATABLE_LAMP = new BlockRotatableLamp();
@ObjectHolder("item_collision_test")
public static final BlockItemCollisionTest ITEM_COLLISION_TEST = new BlockItemCollisionTest();
@ObjectHolder("fluid_tank")
public static final BlockFluidTank FLUID_TANK = new BlockFluidTank();
@ObjectHolder("item_debugger")
public static final BlockItemDebugger ITEM_DEBUGGER = new BlockItemDebugger();
@ObjectHolder("end_portal_frame_full")
public static final Block END_PORTAL_FRAME_FULL = new BlockTestMod3(Material.ROCK, "end_portal_frame_full");
@ObjectHolder("colored_rotatable")
public static final BlockColoredRotatable COLORED_ROTATABLE = new BlockColoredRotatable(Material.CLOTH, "colored_rotatable");
@ObjectHolder("colored_multi_rotatable")
public static final BlockColoredMultiRotatable COLORED_MULTI_ROTATABLE = new BlockColoredMultiRotatable(Material.CLOTH, "colored_multi_rotatable");
@ObjectHolder("potion_effect")
public static final BlockPotionEffect POTION_EFFECT = new BlockPotionEffect();
@ObjectHolder("variants")
public static final BlockVariants VARIANTS = new BlockVariants(Material.IRON);
@ObjectHolder("client_player_rotation")
public static final BlockClientPlayerRotation CLIENT_PLAYER_ROTATION = new BlockClientPlayerRotation();
@ObjectHolder("pig_spawner_refiller")
public static final BlockPigSpawnerRefiller PIG_SPAWNER_REFILLER = new BlockPigSpawnerRefiller();
@ObjectHolder("mirror_plane")
public static final BlockPlane MIRROR_PLANE = new BlockPlane(Material.IRON, "mirror_plane");
@ObjectHolder("vanilla_model_test")
public static final BlockTestMod3 VANILLA_MODEL_TEST = new BlockTestMod3(Material.IRON, "vanilla_model_test");
@ObjectHolder("fullbright")
public static final BlockTestMod3 FULLBRIGHT = (BlockTestMod3) new BlockTestMod3(Material.ROCK, "fullbright").setLightLevel(1);
@ObjectHolder("normal_brightness")
public static final BlockTestMod3 NORMAL_BRIGHTNESS = new BlockTestMod3(Material.ROCK, "normal_brightness");
@ObjectHolder("max_health_setter")
public static final BlockMaxHealthSetter MAX_HEALTH_SETTER = new BlockMaxHealthSetter();
@ObjectHolder("max_health_getter")
public static final BlockMaxHealthGetter MAX_HEALTH_GETTER = new BlockMaxHealthGetter();
@ObjectHolder("small_collision_test")
public static final BlockSmallCollisionTest SMALL_COLLISION_TEST = new BlockSmallCollisionTest();
@ObjectHolder("chest")
public static final BlockModChest CHEST = new BlockModChest();
@ObjectHolder("hidden")
public static final BlockHidden HIDDEN = new BlockHidden(Material.ROCK, "hidden");
@ObjectHolder("basic_pipe")
public static final BlockPipeBasic BASIC_PIPE = new BlockPipeBasic("basic_pipe");
@ObjectHolder("fluid_pipe")
public static final BlockPipeFluid FLUID_PIPE = new BlockPipeFluid();
@ObjectHolder("survival_command_block")
public static final BlockSurvivalCommandBlock SURVIVAL_COMMAND_BLOCK = new BlockSurvivalCommandBlock(TileEntityCommandBlock.Mode.REDSTONE, "survival_command_block");
@ObjectHolder("repeating_survival_command_block")
public static final BlockSurvivalCommandBlock REPEATING_SURVIVAL_COMMAND_BLOCK = new BlockSurvivalCommandBlock(TileEntityCommandBlock.Mode.AUTO, "repeating_survival_command_block");
@ObjectHolder("chain_survival_command_block")
public static final BlockSurvivalCommandBlock CHAIN_SURVIVAL_COMMAND_BLOCK = new BlockSurvivalCommandBlock(TileEntityCommandBlock.Mode.SEQUENCE, "chain_survival_command_block");
public static class Slabs {
public static final BlockColouredSlab.ColouredSlabGroup STAINED_CLAY_SLABS = new BlockColouredSlab.ColouredSlabGroup("stained_clay_slab", Material.ROCK);
}
@Mod.EventBusSubscriber
public static class RegistrationHandler {
public static final Set<ItemBlock> ITEM_BLOCKS = new HashSet<>();
/**
* Register this mod's {@link Block}s.
*
* @param event The event
*/
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> registry = event.getRegistry();
registry.registerAll(
WATER_GRASS,
LARGE_COLLISION_TEST,
RIGHT_CLICK_TEST,
CLIENT_PLAYER_RIGHT_CLICK,
ROTATABLE_LAMP,
ITEM_COLLISION_TEST,
FLUID_TANK,
ITEM_DEBUGGER,
END_PORTAL_FRAME_FULL,
COLORED_ROTATABLE,
COLORED_MULTI_ROTATABLE,
POTION_EFFECT,
VARIANTS,
CLIENT_PLAYER_ROTATION,
PIG_SPAWNER_REFILLER,
MIRROR_PLANE,
VANILLA_MODEL_TEST,
FULLBRIGHT,
NORMAL_BRIGHTNESS,
MAX_HEALTH_SETTER,
MAX_HEALTH_GETTER,
SMALL_COLLISION_TEST,
CHEST,
HIDDEN,
BASIC_PIPE,
FLUID_PIPE,
SURVIVAL_COMMAND_BLOCK,
REPEATING_SURVIVAL_COMMAND_BLOCK,
CHAIN_SURVIVAL_COMMAND_BLOCK
);
registerSlabGroup(registry, Slabs.STAINED_CLAY_SLABS.high);
registerSlabGroup(registry, Slabs.STAINED_CLAY_SLABS.low);
}
/**
* Register the {@link Block}s of a {@link BlockSlabTestMod3.SlabGroup}.
*
* @param registry The registry
* @param slabGroup The slab group
*/
private static void registerSlabGroup(IForgeRegistry<Block> registry, BlockSlabTestMod3.SlabGroup<?, ?, ?> slabGroup) {
registry.register(slabGroup.singleSlab);
registry.register(slabGroup.doubleSlab);
}
/**
* Register this mod's {@link ItemBlock}s.
*
* @param event The event
*/
@SubscribeEvent
public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
final ItemBlock[] items = {
new ItemBlock(WATER_GRASS),
new ItemBlock(LARGE_COLLISION_TEST),
new ItemBlock(RIGHT_CLICK_TEST),
new ItemBlock(CLIENT_PLAYER_RIGHT_CLICK),
new ItemBlock(ROTATABLE_LAMP),
new ItemBlock(ITEM_COLLISION_TEST),
new ItemFluidTank(FLUID_TANK),
new ItemBlock(ITEM_DEBUGGER),
new ItemBlock(END_PORTAL_FRAME_FULL),
new ItemCloth(COLORED_ROTATABLE),
new ItemCloth(COLORED_MULTI_ROTATABLE),
new ItemBlock(POTION_EFFECT),
new ItemMultiTexture(VARIANTS, VARIANTS, VARIANTS::getName),
new ItemBlock(CLIENT_PLAYER_ROTATION),
new ItemBlock(PIG_SPAWNER_REFILLER),
new ItemBlock(MIRROR_PLANE),
new ItemBlock(VANILLA_MODEL_TEST),
new ItemBlock(FULLBRIGHT),
new ItemBlock(NORMAL_BRIGHTNESS),
new ItemBlock(MAX_HEALTH_SETTER),
new ItemBlock(MAX_HEALTH_GETTER),
new ItemBlock(SMALL_COLLISION_TEST),
new ItemBlock(CHEST),
new ItemBlock(HIDDEN),
new ItemBlock(BASIC_PIPE),
new ItemBlock(FLUID_PIPE),
new ItemBlock(SURVIVAL_COMMAND_BLOCK),
new ItemBlock(REPEATING_SURVIVAL_COMMAND_BLOCK),
new ItemBlock(CHAIN_SURVIVAL_COMMAND_BLOCK),
Slabs.STAINED_CLAY_SLABS.low.item,
Slabs.STAINED_CLAY_SLABS.high.item,
};
final IForgeRegistry<Item> registry = event.getRegistry();
for (final ItemBlock item : items) {
registry.register(item.setRegistryName(item.getBlock().getRegistryName()));
ITEM_BLOCKS.add(item);
}
}
}
public static void registerTileEntities() {
registerTileEntity(TileEntitySurvivalCommandBlock.class);
registerTileEntity(TileEntityFluidTank.class);
registerTileEntity(TileEntityColoredRotatable.class);
registerTileEntity(TileEntityColoredMultiRotatable.class);
registerTileEntity(TileEntityPotionEffect.class);
registerTileEntity(TileEntityModChest.class);
registerTileEntity(TileEntityHidden.class);
}
private static void registerTileEntity(Class<? extends TileEntity> tileEntityClass) {
GameRegistry.registerTileEntity(tileEntityClass, Constants.RESOURCE_PREFIX + tileEntityClass.getSimpleName().replaceFirst("TileEntity", ""));
}
}