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;
}
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;
}
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;
}
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;
}
Aggregations