-
Notifications
You must be signed in to change notification settings - Fork 81
/
BlockLootTableProvider.java
149 lines (130 loc) · 5.47 KB
/
BlockLootTableProvider.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
package com.progwml6.natura.common.data.loot;
import com.progwml6.natura.Natura;
import com.progwml6.natura.common.registration.RedwoodBlockObject;
import com.progwml6.natura.gadgets.NaturaGadgets;
import com.progwml6.natura.shared.NaturaCommons;
import com.progwml6.natura.world.NaturaWorld;
import com.progwml6.natura.world.block.TreeType;
import net.minecraft.data.loot.BlockLoot;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.ForgeRegistries;
import slimeknights.mantle.registration.object.BuildingBlockObject;
import slimeknights.mantle.registration.object.FenceBuildingBlockObject;
import slimeknights.mantle.registration.object.WallBuildingBlockObject;
import slimeknights.mantle.registration.object.WoodBlockObject;
import javax.annotation.Nonnull;
import java.util.Objects;
import java.util.stream.Collectors;
public class BlockLootTableProvider extends BlockLoot {
@Nonnull
@Override
protected Iterable<Block> getKnownBlocks() {
return ForgeRegistries.BLOCKS.getValues().stream()
.filter((block) -> Natura.MOD_ID.equals(Objects.requireNonNull(block.getRegistryName()).getNamespace()))
.collect(Collectors.toList());
}
@Override
protected void addTables() {
this.addDecorative();
this.addGadgets();
this.addWorld();
}
private void addDecorative() {
this.registerBuildingLootTables(NaturaCommons.driedClay);
this.registerBuildingLootTables(NaturaCommons.driedClayBricks);
}
private void addGadgets() {
this.dropSelf(NaturaGadgets.stoneLadder.get());
this.dropSelf(NaturaGadgets.stoneTorch.get());
this.dropOther(NaturaGadgets.wallStoneTorch.get(), NaturaGadgets.stoneTorch.get());
this.dropSelf(NaturaGadgets.punji.get());
}
private void addWorld() {
for (TreeType type : TreeType.values()) {
this.add(NaturaWorld.leaves.get(type), (leaves) -> createLeavesDrops(leaves, NaturaWorld.sapling.get(type), NORMAL_LEAVES_SAPLING_CHANCES));
this.dropSelf(NaturaWorld.sapling.get(type));
}
this.registerWoodLootTables(NaturaWorld.maple);
this.registerWoodLootTables(NaturaWorld.silverbell);
this.registerWoodLootTables(NaturaWorld.amaranth);
this.registerWoodLootTables(NaturaWorld.tiger);
this.registerWoodLootTables(NaturaWorld.willow);
this.registerWoodLootTables(NaturaWorld.eucalyptus);
this.registerWoodLootTables(NaturaWorld.hopseed);
this.registerWoodLootTables(NaturaWorld.sakura);
this.registerWoodLootTables(NaturaWorld.redwood);
// this.registerLootTable(NaturaWorld.redwood_leaves.get(), (leaves) -> createLeavesDrops(leaves, NaturaWorld.redwood_sapling.get(), NORMAL_LEAVES_SAPLING_CHANCES));
// this.dropSelf(NaturaWorld.redwood_sapling.get());
//
// this.registerLootTable(NaturaWorld.cotton_crop.get(), droppingAndBonusWhen(NaturaWorld.cotton_crop.get(), NaturaCommons.cotton.get(),
// NaturaWorld.cotton_crop.asItem(), BlockStateProperty.builder(NaturaWorld.cotton_crop.get()).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(CottonCropBlock.AGE, 4))));
//
// this.registerLootTable(NaturaWorld.barley_crop.get(), droppingAndBonusWhen(NaturaWorld.barley_crop.get(), NaturaCommons.barley.get(),
// NaturaWorld.barley_crop.asItem(), BlockStateProperty.builder(NaturaWorld.barley_crop.get()).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(CottonCropBlock.AGE, 3))));
}
/**
* Registers all loot tables for a building block object
*
* @param object Object instance
*/
private void registerBuildingLootTables(BuildingBlockObject object) {
this.dropSelf(object.get());
this.add(object.getSlab(), BlockLoot::createSlabItemTable);
this.dropSelf(object.getStairs());
}
/**
* Registers all loot tables for a wall building block object
*
* @param object Object instance
*/
private void registerWallBuildingLootTables(WallBuildingBlockObject object) {
registerBuildingLootTables(object);
this.dropSelf(object.getWall());
}
/**
* Registers all loot tables for a fence building block object
*
* @param object Object instance
*/
private void registerFenceBuildingLootTables(FenceBuildingBlockObject object) {
registerBuildingLootTables(object);
this.dropSelf(object.getFence());
}
/**
* Adds all loot tables relevant to the given wood object
*/
private void registerWoodLootTables(WoodBlockObject object) {
registerFenceBuildingLootTables(object);
// basic
this.dropSelf(object.getLog());
this.dropSelf(object.getStrippedLog());
this.dropSelf(object.getWood());
this.dropSelf(object.getStrippedWood());
// door
this.dropSelf(object.getFenceGate());
this.add(object.getDoor(), BlockLoot::createDoorTable);
this.dropSelf(object.getTrapdoor());
// redstone
this.dropSelf(object.getPressurePlate());
this.dropSelf(object.getButton());
// sign
this.dropSelf(object.getSign());
}
private void registerWoodLootTables(RedwoodBlockObject object) {
registerFenceBuildingLootTables(object);
// basic
this.dropSelf(object.getBark());
this.dropSelf(object.getHeart());
this.dropSelf(object.getRoot());
// door
this.dropSelf(object.getFenceGate());
this.add(object.getDoor(), BlockLoot::createDoorTable);
this.add(object.getBarkDoor(), BlockLoot::createDoorTable);
this.dropSelf(object.getTrapdoor());
// redstone
this.dropSelf(object.getPressurePlate());
this.dropSelf(object.getButton());
// sign
this.dropSelf(object.getSign());
}
}