-
-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathPoweredBedrock.java
More file actions
76 lines (63 loc) · 2.45 KB
/
Copy pathPoweredBedrock.java
File metadata and controls
76 lines (63 loc) · 2.45 KB
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
package io.github.mooy1.infinityexpansion.items.machines;
import javax.annotation.Nonnull;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import io.github.mooy1.infinityexpansion.InfinityExpansion;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
/**
* A block that becomes bedrock when powered, for decoration of course
*
* @author Mooy1
*/
public final class PoweredBedrock extends SlimefunItem implements EnergyNetComponent {
private final int energy;
public PoweredBedrock(ItemGroup category, SlimefunItemStack item, RecipeType type, ItemStack[] recipe, int energy) {
super(category, item, type, recipe);
this.energy = energy;
addItemHandler(new BlockTicker() {
@Override
public boolean isSynchronized() {
return true;
}
@Override
public void tick(Block b, SlimefunItem item, Config data) {
if (InfinityExpansion.slimefunTickCount() % 8 == 0) {
return;
}
Location l = b.getLocation();
if (getCharge(l) < energy) {
// dupe prevention
if (b.getType() == Material.AIR) {
return;
}
if (b.getType() != Material.NETHERITE_BLOCK) {
b.setType(Material.NETHERITE_BLOCK);
return;
}
}
else if (b.getType() != Material.BEDROCK) {
b.setType(Material.BEDROCK);
}
removeCharge(l, energy);
}
});
}
@Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
}
@Override
public int getCapacity() {
return this.energy * 2;
}
}