Skip to content

Commit

Permalink
[v1.7.6] Merge pull request #270 from bridge-core/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Joelant05 authored Sep 19, 2020
2 parents c72f1dc + a275776 commit f8a9c00
Show file tree
Hide file tree
Showing 2,018 changed files with 13,446 additions and 1,387 deletions.
21 changes: 13 additions & 8 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ Follow the same steps as reporting improper bridge. behavior.

**My entity exists in game, but is invisible.**

If your entity has a shadow but is invisible, give it the `skeleton` material in the client entity file. If it has no shadow, you probably need to add a render
controller.
This could be caused by many different things, such as a mistake in your render controller, a probelm referecing your geometry or incorrectly defining the texture path. For more in depth help with this, check out <a href="https://wiki.bedrock.dev/knowledge/troubleshooting.html">this entity troubleshooting guide</a>.

**My addon isn’t working. Why?**

There are lots of reasons an addon might not work. Before you ask in an addon help channel within the bridge. Discord, please turn on content logs and review any errors.
There are lots of reasons an addon might not work. Before you ask in an addon help channel within the bridge. Discord, please turn on content logs and review any errors.

**How do I turn on content logs?**

In *Minecraft* settings under the Profile section, there are two settings: ”Enable Content Log GUI” and “Enable Content Log File.” We recommend turning both on while
In _Minecraft_ settings under the Profile section, there are two settings: ”Enable Content Log GUI” and “Enable Content Log File.” We recommend turning both on while
testing.
![Enable content logs](https://github.com/bridge-core/bridge./blob/master/images/faq_1.png)

Expand All @@ -49,7 +48,13 @@ available #addon-help channel.
**Do I need experimental gameplay for…?**

As of 1.16.0, the following things require experimental gameplay:
* Biomes
* Features
* Feature rules
* Scripts

- Biomes
- Features
- Feature rules
- Scripts

**My entity's texture is black where there should be transparency.**

This is caused when you're using a material that doesn't support transparency.
`skeleton` and `entity_alphatest` both support transparency and can be used when you have this issue
34 changes: 19 additions & 15 deletions app/renderer/src/AppCycle/startUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,7 @@ export default async function startUp() {
})
}

// Fetch the latest json/version data
fetchLatestJson().then(updateData => {
if (updateData.update_available) {
// If there's an update, notify the user
createNotification({
icon: 'mdi-update',
message: 'Update Available',
textColor: 'white',
onClick: () => {
new UpdateWindow(updateData)
},
})
}
})
createAppUpdateNotification()

if (process.env.NODE_ENV !== 'development') {
let getting_started = createNotification({
Expand All @@ -52,7 +39,7 @@ export default async function startUp() {
textColor: 'white',
onClick: () => {
shell.openExternal(
'https://github.com/bridge-core/bridge./blob/master/GETTING_STARTED.md'
'https://bridge-core.github.io/editor-docs/getting-started/'
)
getting_started.dispose()
},
Expand All @@ -62,3 +49,20 @@ export default async function startUp() {
remote.getCurrentWindow().maximize()
}
}

export function createAppUpdateNotification() {
// Fetch the latest json/version data
fetchLatestJson().then(updateData => {
if (updateData.update_available) {
// If there's an update, notify the user
const notification = createNotification({
icon: 'mdi-update',
message: 'Update Available',
textColor: 'white',
onClick: () => {
new UpdateWindow(updateData, notification)
},
})
}
})
}
21 changes: 21 additions & 0 deletions app/renderer/src/Types/PrismarineNBT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare module 'prismarine-nbt' {
export interface Packet {
type: string
name: string
value: Packet | Packet[] | string | number | boolean
}
export function parse(
data: Buffer,
littleEndian: boolean,
callback: (error: Error, data: Packet) => void
): void
export function writeUncompressed(
data: Packet,
littleEndian: boolean
): Buffer
export function parseUncompressed(
data: Buffer,
littleEndian: boolean
): Packet
export function simplify(data: Packet): any
}
8 changes: 8 additions & 0 deletions app/renderer/src/Types/TGAJS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module 'tga-js' {
export default class TGALoader {
load(uint8arr: Uint8Array): void
open(filePath: string, onLoad: () => void): void
getDataURL(mimeType: 'image/png'): string
getImageData(imageData?: ImageData): ImageData
}
}
2 changes: 0 additions & 2 deletions app/renderer/src/UI/ContextMenu/Folder.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* Define context menu upon right clicking on a folder (FileDisplayer.vue)
*/
import InputWindow from '../Windows/Common/Input'
import trash from 'trash'
import { promises as fs } from 'fs'
import path from 'path'
import { FileExplorer } from '../Sidebar/FileExplorer'
import CreateFileHereWindow from '../../../windows/CreateFileHere'
import { shell } from 'electron'
import {
createInputWindow,
Expand Down
1 change: 1 addition & 0 deletions app/renderer/src/UI/ContextMenu/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:position-x="x_position"
:position-y="y_position"
absolute
transition="slide-y-transition"
>
<v-list color="menu" class="small-list">
<template
Expand Down
2 changes: 2 additions & 0 deletions app/renderer/src/UI/Editor/JsonEditor/HoverCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:close-on-content-click="false"
:position-x="x_position"
:position-y="y_position"
transition="slide-y-transition"
>
<v-card color="background">
<v-card-text>
Expand Down Expand Up @@ -273,6 +274,7 @@ export default {
methods: {
updateComment(val) {
TabSystem.getCurrentNavObj().comment = val
TabSystem.setCurrentUnsaved()
},
updateCurrentComment() {
this.$nextTick(() => {
Expand Down
8 changes: 8 additions & 0 deletions app/renderer/src/UI/Editor/SingleFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
:available_height="available_height"
available_width="100%"
/>
<!--<structure-editor
v-else-if="file_viewer === 'mcstructure'"
:filePath="file.file_path"
:availableHeight="available_height"
/>-->
<json-error-screen
v-else-if="file_viewer === 'json' && json_object == 'error'"
/>
Expand Down Expand Up @@ -60,6 +65,7 @@ import DataUrl from 'dataurl'
import AudioPlayer from './AudioPlayer'
import FileType from '../../editor/FileType'
import ModelEditor from './Model/Main'
import StructureEditor from './Structure/Main'
import TextEditor from './Text/Monaco'
export default {
Expand All @@ -69,6 +75,7 @@ export default {
JsonErrorScreen,
AudioPlayer,
ModelEditor,
StructureEditor,
TextEditor,
},
props: {
Expand Down Expand Up @@ -97,6 +104,7 @@ export default {
else if (this.extension === 'png' || this.extension === 'tga')
return 'image'
else if (this.extension === 'ogg') return 'audio'
else if (this.extension === 'mcstructure') return 'mcstructure'
return 'text'
},
extension() {
Expand Down
74 changes: 74 additions & 0 deletions app/renderer/src/UI/Editor/Structure/Main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<div
v-resize="onResize"
ref="container"
style="width: 100%;"
class="canvas-container"
>
<canvas
:height="availableHeight"
:width="availableWidth"
ref="canvas"
/>

<Hotbar class="canvas-overlay" />
</div>
</template>

<script>
import { loadStructure } from './load'
import Hotbar from '../Voxel/Inventory/Hotbar.vue'
let editor
export default {
name: 'StructureEditor',
props: {
availableHeight: Number,
filePath: String,
},
components: {
Hotbar,
},
async mounted() {
editor = await loadStructure(this.filePath, this.$refs.canvas)
this.onResize()
editor.startRendering()
},
data: () => ({ availableWidth: 0 }),
activated() {
editor.startRendering()
},
deactivated() {
editor.stopRendering()
},
destroyed() {
editor.stopRendering()
},
methods: {
onResize() {
this.availableWidth = this.$refs.container.getBoundingClientRect().width
if (editor !== undefined)
editor.resize(this.availableWidth, this.availableHeight)
},
},
}
</script>

<style scoped>
canvas:focus {
outline: none;
}
.canvas-container {
position: relative;
height: 100%;
width: 100%;
}
.canvas-container canvas,
.canvas-overlay {
position: absolute;
}
</style>
68 changes: 68 additions & 0 deletions app/renderer/src/UI/Editor/Structure/load.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { promises as fs } from 'fs'
import nbt from 'prismarine-nbt'
import { createErrorNotification } from '../../../AppCycle/Errors'
import { createNotification } from '../../Footer/create'
import { createInformationWindow } from '../../Windows/Common/CommonDefinitions'
import { BlockLibrary } from '../Voxel/BlockLibrary/main'
import { createVoxelEditor } from '../Voxel/create'

export async function loadStructure(
filePath: string,
canvas: HTMLCanvasElement
) {
const rawStructure = await fs.readFile(filePath)
const nbtStructure = nbt.parseUncompressed(rawStructure, true)
const {
format_version,
size,
structure,
structure_world_origin,
} = nbt.simplify(nbtStructure)
const { entities, block_indices, palette } = structure
const currentPalette = palette.default.block_palette

//Warning notification - should be removed when this is fixed
if (size[0] > 32 || size[2] > 32) {
let structureWarning = createNotification({
icon: 'mdi-alert-circle-outline',
message: 'Warning',
color: 'error',
textColor: 'white',
onClick: () => {
structureWarning.dispose()
createInformationWindow(
'Warning',
'There is currentlty a bug in minecraft where large structures can be cut off when generated with features and feature rules. The limit seems to be 32x32 on the x and z axis, however this value is inconsistent and can sometimes be lower.'
)
},
})
}

if (format_version !== 1)
return createErrorNotification(
new Error(`Unknown structure format version: ${format_version}`)
)

const editor = await createVoxelEditor(canvas, {
chunkSize: Math.max(...(size as number[])),
tileSize: 16,
renderDistance: 12,
limitedSize: true,
})
const world = editor.getWorld()
console.log(currentPalette)

const layer1 = block_indices[0]
for (let i = 0; i < layer1.length; i++) {
if (layer1[i] === -1) continue

const blockData = currentPalette[layer1[i]]
world.setVoxel(
Math.floor(i / (size[2] * size[1])),
Math.floor(i / size[2]) % size[1],
i % size[2],
BlockLibrary.getRuntimeID(blockData.name)
)
}
return editor
}
Loading

0 comments on commit f8a9c00

Please sign in to comment.