mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
createBlockEntity method
This commit is contained in:
parent
5919d5f031
commit
0d04f79cd4
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@ -16,6 +17,8 @@ public interface WorldHandle {
|
||||
|
||||
EntityType getEntity(String id);
|
||||
|
||||
BlockEntity createBlockEntity(Vector3 location, BlockState block, String snbt);
|
||||
|
||||
/**
|
||||
* Get the locations selected by a player. (Usually via WorldEdit)
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@ -36,6 +37,11 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
return new BukkitEntityType(org.bukkit.entity.EntityType.valueOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(Vector3 location, BlockState block, String snbt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Vector3, Vector3> getSelectedLocation(Player player) {
|
||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.fabric.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
@ -13,6 +14,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.command.argument.BlockArgumentParser;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.StringNbtReader;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
@ -46,6 +49,15 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
return (EntityType) Registry.ENTITY_TYPE.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(Vector3 location, com.dfsek.terra.api.block.state.BlockState block, String snbt) {
|
||||
try {
|
||||
return (BlockEntity) net.minecraft.block.entity.BlockEntity.createFromNbt(FabricAdapter.adapt(location), (BlockState) block, StringNbtReader.parse(snbt));
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Vector3, Vector3> getSelectedLocation(Player player) {
|
||||
try {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.dfsek.terra.sponge.handle;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.sponge.block.SpongeBlockState;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
|
||||
@ -28,4 +30,9 @@ public class SpongeWorldHandle implements WorldHandle {
|
||||
public EntityType getEntity(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(Vector3 location, BlockState block, String snbt) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user