-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathModdedPickaxeItem.java
More file actions
46 lines (41 loc) · 1.79 KB
/
ModdedPickaxeItem.java
File metadata and controls
46 lines (41 loc) · 1.79 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
package net.modificationstation.sltest.item;
import net.minecraft.entity.EntityRegistry;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.modificationstation.stationapi.api.dispenser.ItemDispenseContext;
import net.modificationstation.stationapi.api.item.CustomDispenseBehavior;
import net.modificationstation.stationapi.api.template.item.TemplatePickaxeItem;
import net.modificationstation.stationapi.api.util.Identifier;
import net.modificationstation.stationapi.api.util.math.Direction;
public class ModdedPickaxeItem extends TemplatePickaxeItem implements CustomDispenseBehavior {
public ModdedPickaxeItem(Identifier identifier, ToolMaterial material) {
super(identifier, material);
}
@Override
public boolean useOnBlock(ItemStack item, PlayerEntity player, World level, int x, int y, int z, int facing) {
if (player.isSneaking()) {
if (!level.isRemote) {
level.setBlock(x, y, z, 0);
}
item.bobbingAnimationTime = 20;
return true;
} else if (facing == Direction.UP.ordinal()) {
if (!level.isRemote) {
LivingEntity entity = (LivingEntity) EntityRegistry.create("GPoor", level);
entity.setPosition(x + 0.5, y + 1, z + 0.5);
level.spawnEntity(entity);
entity.animateSpawn();
}
item.bobbingAnimationTime = 20;
return true;
} else
return false;
}
@Override
public void dispense(ItemDispenseContext context) {
LivingEntity entity = (LivingEntity) EntityRegistry.create("GPoor", context.dispenser.world);
context.shootEntity(entity);
}
}