@@ -44,35 +44,38 @@ public class ExpCollector extends SlimefunItem implements InventoryBlock, Energy
44
44
45
45
private final int [] border = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 };
46
46
47
- private static final int ENERGY_CONSUMPTION = 10 ;
48
47
private static final String DATA_KEY = "stored-exp" ;
49
48
49
+ private final double range ;
50
+ private int energyConsumedPerTick = -1 ;
51
+ private int energyCapacity = -1 ;
52
+
50
53
@ ParametersAreNonnullByDefault
51
- public ExpCollector (ItemGroup itemGroup , SlimefunItemStack item , RecipeType recipeType , ItemStack [] recipe ) {
54
+ public ExpCollector (ItemGroup itemGroup , SlimefunItemStack item , RecipeType recipeType , ItemStack [] recipe , double range ) {
52
55
super (itemGroup , item , recipeType , recipe );
53
56
54
57
createPreset (this , this ::constructMenu );
55
58
59
+ this .range = range ;
56
60
addItemHandler (onPlace (), onBreak ());
57
61
}
58
62
59
- @ Nonnull
60
- private BlockPlaceHandler onPlace () {
63
+
64
+ private @ Nonnull BlockPlaceHandler onPlace () {
61
65
return new BlockPlaceHandler (false ) {
62
66
63
67
@ Override
64
- public void onPlayerPlace (BlockPlaceEvent e ) {
68
+ public void onPlayerPlace (@ Nonnull BlockPlaceEvent e ) {
65
69
BlockStorage .addBlockInfo (e .getBlock (), "owner" , e .getPlayer ().getUniqueId ().toString ());
66
70
}
67
71
};
68
72
}
69
73
70
- @ Nonnull
71
- private ItemHandler onBreak () {
74
+ private @ Nonnull ItemHandler onBreak () {
72
75
return new SimpleBlockBreakHandler () {
73
76
74
77
@ Override
75
- public void onBlockBreak (Block b ) {
78
+ public void onBlockBreak (@ Nonnull Block b ) {
76
79
BlockMenu inv = BlockStorage .getInventory (b );
77
80
78
81
if (inv != null ) {
@@ -97,11 +100,6 @@ public EnergyNetComponentType getEnergyComponentType() {
97
100
return EnergyNetComponentType .CONSUMER ;
98
101
}
99
102
100
- @ Override
101
- public int getCapacity () {
102
- return 1024 ;
103
- }
104
-
105
103
protected void constructMenu (BlockMenuPreset preset ) {
106
104
for (int slot : border ) {
107
105
preset .addItem (slot , new CustomItemStack (Material .PURPLE_STAINED_GLASS_PANE , " " ), (p , s , item , action ) -> false );
@@ -132,13 +130,13 @@ protected void tick(Block block) {
132
130
while (iterator .hasNext () && experiencePoints == 0 ) {
133
131
ExperienceOrb orb = (ExperienceOrb ) iterator .next ();
134
132
135
- if (getCharge (location ) < ENERGY_CONSUMPTION ) {
133
+ if (getCharge (location ) < getEnergyConsumption () ) {
136
134
return ;
137
135
}
138
136
139
137
experiencePoints = getStoredExperience (location ) + orb .getExperience ();
140
138
141
- removeCharge (location , ENERGY_CONSUMPTION );
139
+ removeCharge (location , getEnergyConsumption () );
142
140
orb .remove ();
143
141
produceFlasks (location , experiencePoints );
144
142
}
@@ -179,4 +177,21 @@ private int getStoredExperience(Location location) {
179
177
return 0 ;
180
178
}
181
179
}
180
+
181
+ public int getEnergyConsumption () {
182
+ return energyConsumedPerTick ;
183
+ }
184
+
185
+ public void setEnergyConsumption (int energyConsumedPerTick ) {
186
+ this .energyConsumedPerTick = energyConsumedPerTick ;
187
+ }
188
+
189
+ @ Override
190
+ public int getCapacity () {
191
+ return energyCapacity ;
192
+ }
193
+
194
+ public void setCapacity (int energyCapacity ) {
195
+ this .energyCapacity = energyCapacity ;
196
+ }
182
197
}
0 commit comments