Added Block object to the CustomBlock constructor

This commit is contained in:
Felix Cravic 2020-04-28 01:01:54 +02:00
parent f544f090ae
commit 38abe55161
3 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package fr.themode.demo.blocks;
import net.minestom.server.data.Data;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.time.UpdateOption;
@ -10,7 +11,7 @@ import net.minestom.server.utils.time.UpdateOption;
public class StoneBlock extends CustomBlock {
public StoneBlock() {
super((short) 1, "custom_block");
super(Block.STONE, "custom_block");
}
@Override

View File

@ -3,6 +3,7 @@ package fr.themode.demo.blocks;
import net.minestom.server.data.Data;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.time.TimeUnit;
@ -13,7 +14,7 @@ public class UpdatableBlockDemo extends CustomBlock {
private static final UpdateOption UPDATE_OPTION = new UpdateOption(20, TimeUnit.TICK);
public UpdatableBlockDemo() {
super((short) 11, "updatable");
super(Block.DIRT, "updatable");
}
@Override

View File

@ -20,6 +20,10 @@ public abstract class CustomBlock {
this.identifier = identifier;
}
public CustomBlock(Block block, String identifier) {
this(block.getBlockId(), identifier);
}
// TODO add another object parameter which will offer a lot of integrated features (like break animation, id change etc...)
public void update(Instance instance, BlockPosition blockPosition, Data data) {
throw new UnsupportedOperationException("Update method not overridden");