Search in sources :

Example 1 with IsometricRenderScreen

use of com.glisco.isometricrenders.client.gui.IsometricRenderScreen in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeBlockTarget.

private static int executeBlockTarget(FabricClientCommandSource source) {
    final MinecraftClient client = MinecraftClient.getInstance();
    IsometricRenderScreen screen = new IsometricRenderScreen();
    if (client.crosshairTarget.getType() != HitResult.Type.BLOCK) {
        source.sendError(Text.of("You're not looking at a block"));
        return 0;
    }
    final BlockPos hitPos = ((BlockHitResult) client.crosshairTarget).getBlockPos();
    BlockState state = client.world.getBlockState(hitPos);
    BlockEntity be = null;
    if (state.getBlock() instanceof BlockWithEntity) {
        CompoundTag tag = client.world.getBlockEntity(hitPos).toTag(new CompoundTag());
        be = ((BlockWithEntity) state.getBlock()).createBlockEntity(client.world);
        ((BlockEntityAccessor) be).setCachedState(state);
        be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
        CompoundTag copyTag = tag.copy();
        copyTag.putInt("x", 0);
        copyTag.putInt("y", 0);
        copyTag.putInt("z", 0);
        be.fromTag(be.getCachedState(), copyTag);
        be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
    }
    if (be != null) {
        IsometricRenderPresets.setupBlockEntityRender(screen, be);
    } else {
        IsometricRenderPresets.setupBlockStateRender(screen, state);
    }
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) BlockWithEntity(net.minecraft.block.BlockWithEntity) BlockState(net.minecraft.block.BlockState) MinecraftClient(net.minecraft.client.MinecraftClient) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) CompoundTag(net.minecraft.nbt.CompoundTag) BlockEntity(net.minecraft.block.entity.BlockEntity) BlockEntityAccessor(com.glisco.isometricrenders.mixin.BlockEntityAccessor)

Example 2 with IsometricRenderScreen

use of com.glisco.isometricrenders.client.gui.IsometricRenderScreen in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeEntity.

private static int executeEntity(FabricClientCommandSource source, Identifier entityType, CompoundTag entityTag) {
    final MinecraftClient client = MinecraftClient.getInstance();
    IsometricRenderScreen screen = new IsometricRenderScreen();
    entityTag.putString("id", entityType.toString());
    Entity entity = EntityType.loadEntityWithPassengers(entityTag, client.world, Function.identity());
    entity.updatePosition(client.player.getX(), client.player.getY(), client.player.getZ());
    entity.setWorld(client.world);
    if (entity instanceof MobEntity) {
        ((MobEntity) entity).setPersistent();
    }
    IsometricRenderPresets.setupEntityRender(screen, entity);
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) BlockEntity(net.minecraft.block.entity.BlockEntity) MobEntity(net.minecraft.entity.mob.MobEntity) Entity(net.minecraft.entity.Entity) BlockWithEntity(net.minecraft.block.BlockWithEntity) MinecraftClient(net.minecraft.client.MinecraftClient) MobEntity(net.minecraft.entity.mob.MobEntity)

Example 3 with IsometricRenderScreen

use of com.glisco.isometricrenders.client.gui.IsometricRenderScreen in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeItem.

private static int executeItem(FabricClientCommandSource source, ItemStack stack) {
    MinecraftClient client = MinecraftClient.getInstance();
    IsometricRenderScreen screen = new IsometricRenderScreen();
    IsometricRenderPresets.setupItemStackRender(screen, stack);
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) MinecraftClient(net.minecraft.client.MinecraftClient)

Example 4 with IsometricRenderScreen

use of com.glisco.isometricrenders.client.gui.IsometricRenderScreen in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeBlockState.

private static int executeBlockState(FabricClientCommandSource source, BlockState state, CompoundTag tag) {
    IsometricRenderScreen screen = new IsometricRenderScreen();
    BlockEntity be = null;
    if (state.getBlock() instanceof BlockWithEntity) {
        be = ((BlockWithEntity) state.getBlock()).createBlockEntity(MinecraftClient.getInstance().world);
        ((BlockEntityAccessor) be).setCachedState(state);
        be.setLocation(MinecraftClient.getInstance().world, MinecraftClient.getInstance().player.getBlockPos());
        if (tag != null) {
            CompoundTag copyTag = tag.copy();
            copyTag.putInt("x", 0);
            copyTag.putInt("y", 0);
            copyTag.putInt("z", 0);
            be.fromTag(be.getCachedState(), copyTag);
        }
    }
    if (be != null) {
        IsometricRenderPresets.setupBlockEntityRender(screen, be);
    } else {
        IsometricRenderPresets.setupBlockStateRender(screen, state);
    }
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) BlockWithEntity(net.minecraft.block.BlockWithEntity) CompoundTag(net.minecraft.nbt.CompoundTag) BlockEntity(net.minecraft.block.entity.BlockEntity) BlockEntityAccessor(com.glisco.isometricrenders.mixin.BlockEntityAccessor)

Aggregations

AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)4 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)4 BlockWithEntity (net.minecraft.block.BlockWithEntity)3 BlockEntity (net.minecraft.block.entity.BlockEntity)3 MinecraftClient (net.minecraft.client.MinecraftClient)3 BlockEntityAccessor (com.glisco.isometricrenders.mixin.BlockEntityAccessor)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 BlockState (net.minecraft.block.BlockState)1 Entity (net.minecraft.entity.Entity)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 BlockHitResult (net.minecraft.util.hit.BlockHitResult)1 BlockPos (net.minecraft.util.math.BlockPos)1