This commit is contained in:
Sergey 2025-07-04 02:49:36 +03:00
parent f4679c012e
commit 2a06afb374
2469 changed files with 19573 additions and 19292 deletions

View file

@ -22,8 +22,8 @@ public enum ProjectionType {
return this.vertexSorting; return this.vertexSorting;
} }
public void applyLayeringTransform(Matrix4f matrix4f, float f) { public void applyLayeringTransform(Matrix4f modelViewMatrix, float distance) {
this.layeringTransform.apply(matrix4f, f); this.layeringTransform.apply(modelViewMatrix, distance);
} }
@FunctionalInterface @FunctionalInterface

View file

@ -28,25 +28,25 @@ public class TracyFrameCapture implements AutoCloseable {
private int lastCaptureDelay; private int lastCaptureDelay;
private boolean capturedThisFrame; private boolean capturedThisFrame;
private void resize(int i, int j) { private void resize(int width, int height) {
float f = (float)i / j; float f = (float)width / height;
if (i > 320) { if (width > 320) {
i = 320; width = 320;
j = (int)(320.0F / f); height = (int)(320.0F / f);
} }
if (j > 180) { if (height > 180) {
i = (int)(180.0F * f); width = (int)(180.0F * f);
j = 180; height = 180;
} }
i = i / 4 * 4; width = width / 4 * 4;
j = j / 4 * 4; height = height / 4 * 4;
if (this.width != i || this.height != j) { if (this.width != width || this.height != height) {
this.width = i; this.width = width;
this.height = j; this.height = height;
this.frameBuffer.resize(i, j); this.frameBuffer.resize(width, height);
this.pixelbuffer.resize(i * j * 4); this.pixelbuffer.resize(width * height * 4);
if (this.fence != null) { if (this.fence != null) {
this.fence.close(); this.fence.close();
this.fence = null; this.fence = null;

View file

@ -15,7 +15,7 @@ public enum BufferType {
final int id; final int id;
private BufferType(final int j) { private BufferType(final int id) {
this.id = j; this.id = id;
} }
} }

View file

@ -19,9 +19,9 @@ public enum BufferUsage {
final boolean readable; final boolean readable;
final boolean writable; final boolean writable;
private BufferUsage(final int j, final boolean bl, final boolean bl2) { private BufferUsage(final int id, final boolean readable, final boolean writable) {
this.id = j; this.id = id;
this.readable = bl; this.readable = readable;
this.writable = bl2; this.writable = writable;
} }
} }

View file

@ -18,19 +18,19 @@ public class GpuBuffer implements AutoCloseable {
public final int handle; public final int handle;
public int size; public int size;
public GpuBuffer(BufferType bufferType, BufferUsage bufferUsage, int i) { public GpuBuffer(BufferType type, BufferUsage usage, int size) {
this.type = bufferType; this.type = type;
this.size = i; this.size = size;
this.usage = bufferUsage; this.usage = usage;
this.handle = GlStateManager._glGenBuffers(); this.handle = GlStateManager._glGenBuffers();
} }
public GpuBuffer(BufferType bufferType, BufferUsage bufferUsage, ByteBuffer byteBuffer) { public GpuBuffer(BufferType type, BufferUsage usage, ByteBuffer buffer) {
this(bufferType, bufferUsage, byteBuffer.remaining()); this(type, usage, buffer.remaining());
this.write(byteBuffer, 0); this.write(buffer, 0);
} }
public void resize(int i) { public void resize(int size) {
if (this.closed) { if (this.closed) {
throw new IllegalStateException("Buffer already closed"); throw new IllegalStateException("Buffer already closed");
} else { } else {
@ -38,40 +38,40 @@ public class GpuBuffer implements AutoCloseable {
MEMORY_POOl.free(this.handle); MEMORY_POOl.free(this.handle);
} }
this.size = i; this.size = size;
if (this.usage.writable) { if (this.usage.writable) {
this.initialized = false; this.initialized = false;
} else { } else {
this.bind(); this.bind();
GlStateManager._glBufferData(this.type.id, i, this.usage.id); GlStateManager._glBufferData(this.type.id, size, this.usage.id);
MEMORY_POOl.malloc(this.handle, i); MEMORY_POOl.malloc(this.handle, size);
this.initialized = true; this.initialized = true;
} }
} }
} }
public void write(ByteBuffer byteBuffer, int i) { public void write(ByteBuffer buffer, int offset) {
if (this.closed) { if (this.closed) {
throw new IllegalStateException("Buffer already closed"); throw new IllegalStateException("Buffer already closed");
} else if (!this.usage.writable) { } else if (!this.usage.writable) {
throw new IllegalStateException("Buffer is not writable"); throw new IllegalStateException("Buffer is not writable");
} else { } else {
int j = byteBuffer.remaining(); int i = buffer.remaining();
if (j + i > this.size) { if (i + offset > this.size) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot write more data than this buffer can hold (attempting to write " + j + " bytes at offset " + i + " to " + this.size + " size buffer)" "Cannot write more data than this buffer can hold (attempting to write " + i + " bytes at offset " + offset + " to " + this.size + " size buffer)"
); );
} else { } else {
this.bind(); this.bind();
if (this.initialized) { if (this.initialized) {
GlStateManager._glBufferSubData(this.type.id, i, byteBuffer); GlStateManager._glBufferSubData(this.type.id, offset, buffer);
} else if (i == 0 && j == this.size) { } else if (offset == 0 && i == this.size) {
GlStateManager._glBufferData(this.type.id, byteBuffer, this.usage.id); GlStateManager._glBufferData(this.type.id, buffer, this.usage.id);
MEMORY_POOl.malloc(this.handle, this.size); MEMORY_POOl.malloc(this.handle, this.size);
this.initialized = true; this.initialized = true;
} else { } else {
GlStateManager._glBufferData(this.type.id, this.size, this.usage.id); GlStateManager._glBufferData(this.type.id, this.size, this.usage.id);
GlStateManager._glBufferSubData(this.type.id, i, byteBuffer); GlStateManager._glBufferSubData(this.type.id, offset, buffer);
MEMORY_POOl.malloc(this.handle, this.size); MEMORY_POOl.malloc(this.handle, this.size);
this.initialized = true; this.initialized = true;
} }
@ -85,18 +85,18 @@ public class GpuBuffer implements AutoCloseable {
} }
@Nullable @Nullable
public GpuBuffer.ReadView read(int i, int j) { public GpuBuffer.ReadView read(int offset, int length) {
if (this.closed) { if (this.closed) {
throw new IllegalStateException("Buffer already closed"); throw new IllegalStateException("Buffer already closed");
} else if (!this.usage.readable) { } else if (!this.usage.readable) {
throw new IllegalStateException("Buffer is not readable"); throw new IllegalStateException("Buffer is not readable");
} else if (i + j > this.size) { } else if (offset + length > this.size) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot read more data than this buffer can hold (attempting to read " + j + " bytes at offset " + i + " from " + this.size + " size buffer)" "Cannot read more data than this buffer can hold (attempting to read " + length + " bytes at offset " + offset + " from " + this.size + " size buffer)"
); );
} else { } else {
this.bind(); this.bind();
ByteBuffer byteBuffer = GlStateManager._glMapBufferRange(this.type.id, i, j, 1); ByteBuffer byteBuffer = GlStateManager._glMapBufferRange(this.type.id, offset, length, 1);
return byteBuffer == null ? null : new GpuBuffer.ReadView(this.type.id, byteBuffer); return byteBuffer == null ? null : new GpuBuffer.ReadView(this.type.id, byteBuffer);
} }
} }
@ -120,9 +120,9 @@ public class GpuBuffer implements AutoCloseable {
private final int target; private final int target;
private final ByteBuffer data; private final ByteBuffer data;
protected ReadView(int i, ByteBuffer byteBuffer) { protected ReadView(int target, ByteBuffer data) {
this.target = i; this.target = target;
this.data = byteBuffer; this.data = data;
} }
public ByteBuffer data() { public ByteBuffer data() {

View file

@ -15,11 +15,11 @@ public class GpuFence implements AutoCloseable {
} }
} }
public boolean awaitCompletion(long l) { public boolean awaitCompletion(long timeout) {
if (this.handle == 0L) { if (this.handle == 0L) {
return true; return true;
} else { } else {
int i = GlStateManager._glClientWaitSync(this.handle, 0, l); int i = GlStateManager._glClientWaitSync(this.handle, 0, timeout);
if (i == 37147) { if (i == 37147) {
return false; return false;
} else if (i == 37149) { } else if (i == 37149) {

View file

@ -71,14 +71,14 @@ public class TrueTypeGlyphProvider implements GlyphProvider {
return glyphEntry != null ? this.getOrLoadGlyphInfo(character, glyphEntry) : null; return glyphEntry != null ? this.getOrLoadGlyphInfo(character, glyphEntry) : null;
} }
private GlyphInfo getOrLoadGlyphInfo(int i, TrueTypeGlyphProvider.GlyphEntry glyphEntry) { private GlyphInfo getOrLoadGlyphInfo(int character, TrueTypeGlyphProvider.GlyphEntry glyphEntry) {
GlyphInfo glyphInfo = glyphEntry.glyph; GlyphInfo glyphInfo = glyphEntry.glyph;
if (glyphInfo == null) { if (glyphInfo == null) {
FT_Face fT_Face = this.validateFontOpen(); FT_Face fT_Face = this.validateFontOpen();
synchronized (fT_Face) { synchronized (fT_Face) {
glyphInfo = glyphEntry.glyph; glyphInfo = glyphEntry.glyph;
if (glyphInfo == null) { if (glyphInfo == null) {
glyphInfo = this.loadGlyph(i, fT_Face, glyphEntry.index); glyphInfo = this.loadGlyph(character, fT_Face, glyphEntry.index);
glyphEntry.glyph = glyphInfo; glyphEntry.glyph = glyphInfo;
} }
} }
@ -87,23 +87,23 @@ public class TrueTypeGlyphProvider implements GlyphProvider {
return glyphInfo; return glyphInfo;
} }
private GlyphInfo loadGlyph(int i, FT_Face fT_Face, int j) { private GlyphInfo loadGlyph(int character, FT_Face face, int index) {
int k = FreeType.FT_Load_Glyph(fT_Face, j, 4194312); int i = FreeType.FT_Load_Glyph(face, index, 4194312);
if (k != 0) { if (i != 0) {
FreeTypeUtil.assertError(k, String.format(Locale.ROOT, "Loading glyph U+%06X", i)); FreeTypeUtil.assertError(i, String.format(Locale.ROOT, "Loading glyph U+%06X", character));
} }
FT_GlyphSlot fT_GlyphSlot = fT_Face.glyph(); FT_GlyphSlot fT_GlyphSlot = face.glyph();
if (fT_GlyphSlot == null) { if (fT_GlyphSlot == null) {
throw new NullPointerException(String.format(Locale.ROOT, "Glyph U+%06X not initialized", i)); throw new NullPointerException(String.format(Locale.ROOT, "Glyph U+%06X not initialized", character));
} else { } else {
float f = FreeTypeUtil.x(fT_GlyphSlot.advance()); float f = FreeTypeUtil.x(fT_GlyphSlot.advance());
FT_Bitmap fT_Bitmap = fT_GlyphSlot.bitmap(); FT_Bitmap fT_Bitmap = fT_GlyphSlot.bitmap();
int l = fT_GlyphSlot.bitmap_left(); int j = fT_GlyphSlot.bitmap_left();
int m = fT_GlyphSlot.bitmap_top(); int k = fT_GlyphSlot.bitmap_top();
int n = fT_Bitmap.width(); int l = fT_Bitmap.width();
int o = fT_Bitmap.rows(); int m = fT_Bitmap.rows();
return (GlyphInfo)(n > 0 && o > 0 ? new TrueTypeGlyphProvider.Glyph(l, m, n, o, f, j) : () -> f / this.oversample); return (GlyphInfo)(l > 0 && m > 0 ? new TrueTypeGlyphProvider.Glyph(j, k, l, m, f, index) : () -> f / this.oversample);
} }
} }
@ -169,8 +169,8 @@ public class TrueTypeGlyphProvider implements GlyphProvider {
@Nullable @Nullable
volatile GlyphInfo glyph; volatile GlyphInfo glyph;
GlyphEntry(int i) { GlyphEntry(int index) {
this.index = i; this.index = index;
} }
} }
} }

View file

@ -22,36 +22,36 @@ public class FrameGraphBuilder {
private final List<FrameGraphBuilder.ExternalResource<?>> externalResources = new ArrayList(); private final List<FrameGraphBuilder.ExternalResource<?>> externalResources = new ArrayList();
private final List<FrameGraphBuilder.Pass> passes = new ArrayList(); private final List<FrameGraphBuilder.Pass> passes = new ArrayList();
public FramePass addPass(String string) { public FramePass addPass(String name) {
FrameGraphBuilder.Pass pass = new FrameGraphBuilder.Pass(this.passes.size(), string); FrameGraphBuilder.Pass pass = new FrameGraphBuilder.Pass(this.passes.size(), name);
this.passes.add(pass); this.passes.add(pass);
return pass; return pass;
} }
public <T> ResourceHandle<T> importExternal(String string, T object) { public <T> ResourceHandle<T> importExternal(String name, T resource) {
FrameGraphBuilder.ExternalResource<T> externalResource = new FrameGraphBuilder.ExternalResource<>(string, null, object); FrameGraphBuilder.ExternalResource<T> externalResource = new FrameGraphBuilder.ExternalResource<>(name, null, resource);
this.externalResources.add(externalResource); this.externalResources.add(externalResource);
return externalResource.handle; return externalResource.handle;
} }
public <T> ResourceHandle<T> createInternal(String string, ResourceDescriptor<T> resourceDescriptor) { public <T> ResourceHandle<T> createInternal(String name, ResourceDescriptor<T> descriptor) {
return this.createInternalResource(string, resourceDescriptor, null).handle; return this.createInternalResource(name, descriptor, null).handle;
} }
<T> FrameGraphBuilder.InternalVirtualResource<T> createInternalResource( <T> FrameGraphBuilder.InternalVirtualResource<T> createInternalResource(
String string, ResourceDescriptor<T> resourceDescriptor, @Nullable FrameGraphBuilder.Pass pass String name, ResourceDescriptor<T> descriptor, @Nullable FrameGraphBuilder.Pass createdBy
) { ) {
int i = this.internalResources.size(); int i = this.internalResources.size();
FrameGraphBuilder.InternalVirtualResource<T> internalVirtualResource = new FrameGraphBuilder.InternalVirtualResource<>(i, string, pass, resourceDescriptor); FrameGraphBuilder.InternalVirtualResource<T> internalVirtualResource = new FrameGraphBuilder.InternalVirtualResource<>(i, name, createdBy, descriptor);
this.internalResources.add(internalVirtualResource); this.internalResources.add(internalVirtualResource);
return internalVirtualResource; return internalVirtualResource;
} }
public void execute(GraphicsResourceAllocator graphicsResourceAllocator) { public void execute(GraphicsResourceAllocator allocator) {
this.execute(graphicsResourceAllocator, FrameGraphBuilder.Inspector.NONE); this.execute(allocator, FrameGraphBuilder.Inspector.NONE);
} }
public void execute(GraphicsResourceAllocator graphicsResourceAllocator, FrameGraphBuilder.Inspector inspector) { public void execute(GraphicsResourceAllocator allocator, FrameGraphBuilder.Inspector inspector) {
BitSet bitSet = this.identifyPassesToKeep(); BitSet bitSet = this.identifyPassesToKeep();
List<FrameGraphBuilder.Pass> list = new ArrayList(bitSet.cardinality()); List<FrameGraphBuilder.Pass> list = new ArrayList(bitSet.cardinality());
BitSet bitSet2 = new BitSet(this.passes.size()); BitSet bitSet2 = new BitSet(this.passes.size());
@ -65,7 +65,7 @@ public class FrameGraphBuilder {
for (FrameGraphBuilder.Pass pass : list) { for (FrameGraphBuilder.Pass pass : list) {
for (FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource : pass.resourcesToAcquire) { for (FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource : pass.resourcesToAcquire) {
inspector.acquireResource(internalVirtualResource.name); inspector.acquireResource(internalVirtualResource.name);
internalVirtualResource.acquire(graphicsResourceAllocator); internalVirtualResource.acquire(allocator);
} }
inspector.beforeExecutePass(pass.name); inspector.beforeExecutePass(pass.name);
@ -75,7 +75,7 @@ public class FrameGraphBuilder {
for (int i = pass.resourcesToRelease.nextSetBit(0); i >= 0; i = pass.resourcesToRelease.nextSetBit(i + 1)) { for (int i = pass.resourcesToRelease.nextSetBit(0); i >= 0; i = pass.resourcesToRelease.nextSetBit(i + 1)) {
FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource = (FrameGraphBuilder.InternalVirtualResource<?>)this.internalResources.get(i); FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource = (FrameGraphBuilder.InternalVirtualResource<?>)this.internalResources.get(i);
inspector.releaseResource(internalVirtualResource.name); inspector.releaseResource(internalVirtualResource.name);
internalVirtualResource.release(graphicsResourceAllocator); internalVirtualResource.release(allocator);
} }
} }
} }
@ -100,50 +100,50 @@ public class FrameGraphBuilder {
return bitSet; return bitSet;
} }
private void discoverAllRequiredPasses(FrameGraphBuilder.Pass pass, BitSet bitSet, Deque<FrameGraphBuilder.Pass> deque) { private void discoverAllRequiredPasses(FrameGraphBuilder.Pass pass, BitSet passesToKeep, Deque<FrameGraphBuilder.Pass> output) {
deque.add(pass); output.add(pass);
while (!deque.isEmpty()) { while (!output.isEmpty()) {
FrameGraphBuilder.Pass pass2 = (FrameGraphBuilder.Pass)deque.poll(); FrameGraphBuilder.Pass pass2 = (FrameGraphBuilder.Pass)output.poll();
if (!bitSet.get(pass2.id)) { if (!passesToKeep.get(pass2.id)) {
bitSet.set(pass2.id); passesToKeep.set(pass2.id);
for (int i = pass2.requiredPassIds.nextSetBit(0); i >= 0; i = pass2.requiredPassIds.nextSetBit(i + 1)) { for (int i = pass2.requiredPassIds.nextSetBit(0); i >= 0; i = pass2.requiredPassIds.nextSetBit(i + 1)) {
deque.add((FrameGraphBuilder.Pass)this.passes.get(i)); output.add((FrameGraphBuilder.Pass)this.passes.get(i));
} }
} }
} }
} }
private void resolvePassOrder(FrameGraphBuilder.Pass pass, BitSet bitSet, BitSet bitSet2, List<FrameGraphBuilder.Pass> list) { private void resolvePassOrder(FrameGraphBuilder.Pass pass, BitSet passesToKeep, BitSet output, List<FrameGraphBuilder.Pass> orderedPasses) {
if (bitSet2.get(pass.id)) { if (output.get(pass.id)) {
String string = (String)bitSet2.stream().mapToObj(ix -> ((FrameGraphBuilder.Pass)this.passes.get(ix)).name).collect(Collectors.joining(", ")); String string = (String)output.stream().mapToObj(ix -> ((FrameGraphBuilder.Pass)this.passes.get(ix)).name).collect(Collectors.joining(", "));
throw new IllegalStateException("Frame graph cycle detected between " + string); throw new IllegalStateException("Frame graph cycle detected between " + string);
} else if (bitSet.get(pass.id)) { } else if (passesToKeep.get(pass.id)) {
bitSet2.set(pass.id); output.set(pass.id);
bitSet.clear(pass.id); passesToKeep.clear(pass.id);
for (int i = pass.requiredPassIds.nextSetBit(0); i >= 0; i = pass.requiredPassIds.nextSetBit(i + 1)) { for (int i = pass.requiredPassIds.nextSetBit(0); i >= 0; i = pass.requiredPassIds.nextSetBit(i + 1)) {
this.resolvePassOrder((FrameGraphBuilder.Pass)this.passes.get(i), bitSet, bitSet2, list); this.resolvePassOrder((FrameGraphBuilder.Pass)this.passes.get(i), passesToKeep, output, orderedPasses);
} }
for (FrameGraphBuilder.Handle<?> handle : pass.writesFrom) { for (FrameGraphBuilder.Handle<?> handle : pass.writesFrom) {
for (int j = handle.readBy.nextSetBit(0); j >= 0; j = handle.readBy.nextSetBit(j + 1)) { for (int j = handle.readBy.nextSetBit(0); j >= 0; j = handle.readBy.nextSetBit(j + 1)) {
if (j != pass.id) { if (j != pass.id) {
this.resolvePassOrder((FrameGraphBuilder.Pass)this.passes.get(j), bitSet, bitSet2, list); this.resolvePassOrder((FrameGraphBuilder.Pass)this.passes.get(j), passesToKeep, output, orderedPasses);
} }
} }
} }
list.add(pass); orderedPasses.add(pass);
bitSet2.clear(pass.id); output.clear(pass.id);
} }
} }
private void assignResourceLifetimes(Collection<FrameGraphBuilder.Pass> collection) { private void assignResourceLifetimes(Collection<FrameGraphBuilder.Pass> passes) {
FrameGraphBuilder.Pass[] passs = new FrameGraphBuilder.Pass[this.internalResources.size()]; FrameGraphBuilder.Pass[] passs = new FrameGraphBuilder.Pass[this.internalResources.size()];
for (FrameGraphBuilder.Pass pass : collection) { for (FrameGraphBuilder.Pass pass : passes) {
for (int i = pass.requiredResourceIds.nextSetBit(0); i >= 0; i = pass.requiredResourceIds.nextSetBit(i + 1)) { for (int i = pass.requiredResourceIds.nextSetBit(0); i >= 0; i = pass.requiredResourceIds.nextSetBit(i + 1)) {
FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource = (FrameGraphBuilder.InternalVirtualResource<?>)this.internalResources.get(i); FrameGraphBuilder.InternalVirtualResource<?> internalVirtualResource = (FrameGraphBuilder.InternalVirtualResource<?>)this.internalResources.get(i);
FrameGraphBuilder.Pass pass2 = passs[i]; FrameGraphBuilder.Pass pass2 = passs[i];
@ -163,9 +163,9 @@ public class FrameGraphBuilder {
static class ExternalResource<T> extends FrameGraphBuilder.VirtualResource<T> { static class ExternalResource<T> extends FrameGraphBuilder.VirtualResource<T> {
private final T resource; private final T resource;
public ExternalResource(String string, @Nullable FrameGraphBuilder.Pass pass, T object) { public ExternalResource(String name, @Nullable FrameGraphBuilder.Pass createdBy, T resource) {
super(string, pass); super(name, createdBy);
this.resource = object; this.resource = resource;
} }
@Override @Override
@ -184,10 +184,10 @@ public class FrameGraphBuilder {
@Nullable @Nullable
private FrameGraphBuilder.Handle<T> aliasedBy; private FrameGraphBuilder.Handle<T> aliasedBy;
Handle(FrameGraphBuilder.VirtualResource<T> virtualResource, int i, @Nullable FrameGraphBuilder.Pass pass) { Handle(FrameGraphBuilder.VirtualResource<T> holder, int version, @Nullable FrameGraphBuilder.Pass createdBy) {
this.holder = virtualResource; this.holder = holder;
this.version = i; this.version = version;
this.createdBy = pass; this.createdBy = createdBy;
} }
@Override @Override
@ -195,11 +195,11 @@ public class FrameGraphBuilder {
return this.holder.get(); return this.holder.get();
} }
FrameGraphBuilder.Handle<T> writeAndAlias(FrameGraphBuilder.Pass pass) { FrameGraphBuilder.Handle<T> writeAndAlias(FrameGraphBuilder.Pass alias) {
if (this.holder.handle != this) { if (this.holder.handle != this) {
throw new IllegalStateException("Handle " + this + " is no longer valid, as its contents were moved into " + this.aliasedBy); throw new IllegalStateException("Handle " + this + " is no longer valid, as its contents were moved into " + this.aliasedBy);
} else { } else {
FrameGraphBuilder.Handle<T> handle = new FrameGraphBuilder.Handle<>(this.holder, this.version + 1, pass); FrameGraphBuilder.Handle<T> handle = new FrameGraphBuilder.Handle<>(this.holder, this.version + 1, alias);
this.holder.handle = handle; this.holder.handle = handle;
this.aliasedBy = handle; this.aliasedBy = handle;
return handle; return handle;
@ -215,16 +215,16 @@ public class FrameGraphBuilder {
public interface Inspector { public interface Inspector {
FrameGraphBuilder.Inspector NONE = new 1(); FrameGraphBuilder.Inspector NONE = new 1();
default void acquireResource(String string) { default void acquireResource(String name) {
} }
default void releaseResource(String string) { default void releaseResource(String name) {
} }
default void beforeExecutePass(String string) { default void beforeExecutePass(String name) {
} }
default void afterExecutePass(String string) { default void afterExecutePass(String name) {
} }
} }
@ -235,10 +235,10 @@ public class FrameGraphBuilder {
@Nullable @Nullable
private T physicalResource; private T physicalResource;
public InternalVirtualResource(int i, String string, @Nullable FrameGraphBuilder.Pass pass, ResourceDescriptor<T> resourceDescriptor) { public InternalVirtualResource(int id, String name, @Nullable FrameGraphBuilder.Pass createdBy, ResourceDescriptor<T> descriptor) {
super(string, pass); super(name, createdBy);
this.id = i; this.id = id;
this.descriptor = resourceDescriptor; this.descriptor = descriptor;
} }
@Override @Override
@ -246,19 +246,19 @@ public class FrameGraphBuilder {
return (T)Objects.requireNonNull(this.physicalResource, "Resource is not currently available"); return (T)Objects.requireNonNull(this.physicalResource, "Resource is not currently available");
} }
public void acquire(GraphicsResourceAllocator graphicsResourceAllocator) { public void acquire(GraphicsResourceAllocator allocator) {
if (this.physicalResource != null) { if (this.physicalResource != null) {
throw new IllegalStateException("Tried to acquire physical resource, but it was already assigned"); throw new IllegalStateException("Tried to acquire physical resource, but it was already assigned");
} else { } else {
this.physicalResource = graphicsResourceAllocator.acquire(this.descriptor); this.physicalResource = allocator.acquire(this.descriptor);
} }
} }
public void release(GraphicsResourceAllocator graphicsResourceAllocator) { public void release(GraphicsResourceAllocator allocator) {
if (this.physicalResource == null) { if (this.physicalResource == null) {
throw new IllegalStateException("Tried to release physical resource that was not allocated"); throw new IllegalStateException("Tried to release physical resource that was not allocated");
} else { } else {
graphicsResourceAllocator.release(this.descriptor, this.physicalResource); allocator.release(this.descriptor, this.physicalResource);
this.physicalResource = null; this.physicalResource = null;
} }
} }
@ -276,9 +276,9 @@ public class FrameGraphBuilder {
final BitSet resourcesToRelease = new BitSet(); final BitSet resourcesToRelease = new BitSet();
boolean disableCulling; boolean disableCulling;
public Pass(final int i, final String string) { public Pass(final int id, final String name) {
this.id = i; this.id = id;
this.name = string; this.name = name;
} }
private <T> void markResourceRequired(FrameGraphBuilder.Handle<T> handle) { private <T> void markResourceRequired(FrameGraphBuilder.Handle<T> handle) {
@ -292,15 +292,15 @@ public class FrameGraphBuilder {
} }
@Override @Override
public <T> ResourceHandle<T> createsInternal(String string, ResourceDescriptor<T> resourceDescriptor) { public <T> ResourceHandle<T> createsInternal(String name, ResourceDescriptor<T> descriptor) {
FrameGraphBuilder.InternalVirtualResource<T> internalVirtualResource = FrameGraphBuilder.this.createInternalResource(string, resourceDescriptor, this); FrameGraphBuilder.InternalVirtualResource<T> internalVirtualResource = FrameGraphBuilder.this.createInternalResource(name, descriptor, this);
this.requiredResourceIds.set(internalVirtualResource.id); this.requiredResourceIds.set(internalVirtualResource.id);
return internalVirtualResource.handle; return internalVirtualResource.handle;
} }
@Override @Override
public <T> void reads(ResourceHandle<T> resourceHandle) { public <T> void reads(ResourceHandle<T> handle) {
this._reads((FrameGraphBuilder.Handle<T>)resourceHandle); this._reads((FrameGraphBuilder.Handle<T>)handle);
} }
private <T> void _reads(FrameGraphBuilder.Handle<T> handle) { private <T> void _reads(FrameGraphBuilder.Handle<T> handle) {
@ -313,13 +313,13 @@ public class FrameGraphBuilder {
} }
@Override @Override
public <T> ResourceHandle<T> readsAndWrites(ResourceHandle<T> resourceHandle) { public <T> ResourceHandle<T> readsAndWrites(ResourceHandle<T> handle) {
return this._readsAndWrites((FrameGraphBuilder.Handle<T>)resourceHandle); return this._readsAndWrites((FrameGraphBuilder.Handle<T>)handle);
} }
@Override @Override
public void requires(FramePass framePass) { public void requires(FramePass pass) {
this.requiredPassIds.set(((FrameGraphBuilder.Pass)framePass).id); this.requiredPassIds.set(((FrameGraphBuilder.Pass)pass).id);
} }
@Override @Override
@ -334,8 +334,8 @@ public class FrameGraphBuilder {
} }
@Override @Override
public void executes(Runnable runnable) { public void executes(Runnable task) {
this.task = runnable; this.task = task;
} }
public String toString() { public String toString() {
@ -348,9 +348,9 @@ public class FrameGraphBuilder {
public final String name; public final String name;
public FrameGraphBuilder.Handle<T> handle; public FrameGraphBuilder.Handle<T> handle;
public VirtualResource(String string, @Nullable FrameGraphBuilder.Pass pass) { public VirtualResource(String name, @Nullable FrameGraphBuilder.Pass createdBy) {
this.name = string; this.name = name;
this.handle = new FrameGraphBuilder.Handle<>(this, 0, pass); this.handle = new FrameGraphBuilder.Handle<>(this, 0, createdBy);
} }
public abstract T get(); public abstract T get();

View file

@ -7,15 +7,15 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public interface FramePass { public interface FramePass {
<T> ResourceHandle<T> createsInternal(String string, ResourceDescriptor<T> resourceDescriptor); <T> ResourceHandle<T> createsInternal(String name, ResourceDescriptor<T> descriptor);
<T> void reads(ResourceHandle<T> resourceHandle); <T> void reads(ResourceHandle<T> handle);
<T> ResourceHandle<T> readsAndWrites(ResourceHandle<T> resourceHandle); <T> ResourceHandle<T> readsAndWrites(ResourceHandle<T> handle);
void requires(FramePass framePass); void requires(FramePass pass);
void disableCulling(); void disableCulling();
void executes(Runnable runnable); void executes(Runnable task);
} }

View file

@ -38,14 +38,14 @@ public abstract class RenderTarget {
this.depthBufferId = -1; this.depthBufferId = -1;
} }
public void resize(int i, int j) { public void resize(int width, int height) {
RenderSystem.assertOnRenderThreadOrInit(); RenderSystem.assertOnRenderThreadOrInit();
GlStateManager._enableDepthTest(); GlStateManager._enableDepthTest();
if (this.frameBufferId >= 0) { if (this.frameBufferId >= 0) {
this.destroyBuffers(); this.destroyBuffers();
} }
this.createBuffers(i, j); this.createBuffers(width, height);
GlStateManager._glBindFramebuffer(36160, 0); GlStateManager._glBindFramebuffer(36160, 0);
} }
@ -78,14 +78,14 @@ public abstract class RenderTarget {
GlStateManager._glBindFramebuffer(36160, 0); GlStateManager._glBindFramebuffer(36160, 0);
} }
public void createBuffers(int i, int j) { public void createBuffers(int width, int height) {
RenderSystem.assertOnRenderThreadOrInit(); RenderSystem.assertOnRenderThreadOrInit();
int k = RenderSystem.maxSupportedTextureSize(); int i = RenderSystem.maxSupportedTextureSize();
if (i > 0 && i <= k && j > 0 && j <= k) { if (width > 0 && width <= i && height > 0 && height <= i) {
this.viewWidth = i; this.viewWidth = width;
this.viewHeight = j; this.viewHeight = height;
this.width = i; this.width = width;
this.height = j; this.height = height;
this.frameBufferId = GlStateManager.glGenFramebuffers(); this.frameBufferId = GlStateManager.glGenFramebuffers();
this.colorTextureId = TextureUtil.generateTextureId(); this.colorTextureId = TextureUtil.generateTextureId();
if (this.useDepth) { if (this.useDepth) {
@ -114,7 +114,7 @@ public abstract class RenderTarget {
this.clear(); this.clear();
this.unbindRead(); this.unbindRead();
} else { } else {
throw new IllegalArgumentException("Window " + i + "x" + j + " size out of bounds (max. size: " + k + ")"); throw new IllegalArgumentException("Window " + width + "x" + height + " size out of bounds (max. size: " + i + ")");
} }
} }
@ -191,12 +191,12 @@ public abstract class RenderTarget {
GlStateManager._glBindFramebuffer(36008, 0); GlStateManager._glBindFramebuffer(36008, 0);
} }
public void blitAndBlendToScreen(int i, int j) { public void blitAndBlendToScreen(int width, int height) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
GlStateManager._colorMask(true, true, true, false); GlStateManager._colorMask(true, true, true, false);
GlStateManager._disableDepthTest(); GlStateManager._disableDepthTest();
GlStateManager._depthMask(false); GlStateManager._depthMask(false);
GlStateManager._viewport(0, 0, i, j); GlStateManager._viewport(0, 0, width, height);
CompiledShaderProgram compiledShaderProgram = (CompiledShaderProgram)Objects.requireNonNull( CompiledShaderProgram compiledShaderProgram = (CompiledShaderProgram)Objects.requireNonNull(
RenderSystem.setShader(CoreShaders.BLIT_SCREEN), "Blit shader not loaded" RenderSystem.setShader(CoreShaders.BLIT_SCREEN), "Blit shader not loaded"
); );

View file

@ -6,9 +6,9 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class TextureTarget extends RenderTarget { public class TextureTarget extends RenderTarget {
public TextureTarget(int i, int j, boolean bl) { public TextureTarget(int width, int height, boolean useDepth) {
super(bl); super(useDepth);
RenderSystem.assertOnRenderThreadOrInit(); RenderSystem.assertOnRenderThreadOrInit();
this.resize(i, j); this.resize(width, height);
} }
} }

View file

@ -12,7 +12,7 @@ import net.minecraft.server.dedicated.ServerWatchdog;
public class ClientShutdownWatchdog { public class ClientShutdownWatchdog {
private static final Duration CRASH_REPORT_PRELOAD_LOAD = Duration.ofSeconds(15L); private static final Duration CRASH_REPORT_PRELOAD_LOAD = Duration.ofSeconds(15L);
public static void startShutdownWatchdog(File file, long l) { public static void startShutdownWatchdog(File file, long threadId) {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
Thread.sleep(CRASH_REPORT_PRELOAD_LOAD); Thread.sleep(CRASH_REPORT_PRELOAD_LOAD);
@ -20,7 +20,7 @@ public class ClientShutdownWatchdog {
return; return;
} }
CrashReport crashReport = ServerWatchdog.createWatchdogCrashReport("Client shutdown", l); CrashReport crashReport = ServerWatchdog.createWatchdogCrashReport("Client shutdown", threadId);
Minecraft.saveReport(file, crashReport); Minecraft.saveReport(file, crashReport);
}); });
thread.setDaemon(true); thread.setDaemon(true);

View file

@ -46,8 +46,8 @@ public class FramerateLimitTracker {
} }
} }
public void setFramerateLimit(int i) { public void setFramerateLimit(int framerateLimit) {
this.framerateLimit = i; this.framerateLimit = framerateLimit;
} }
public void onInputReceived() { public void onInputReceived() {

View file

@ -864,9 +864,9 @@ public class GlStateManager {
static class FramebufferState { static class FramebufferState {
public int binding; public int binding;
public boolean update(int i) { public boolean update(int binding) {
if (i != this.binding) { if (binding != this.binding) {
this.binding = i; this.binding = binding;
return true; return true;
} else { } else {
return false; return false;

View file

@ -204,36 +204,36 @@ public final class NativeImage implements AutoCloseable {
return this.format; return this.format;
} }
private int getPixelABGR(int i, int j) { private int getPixelABGR(int x, int y) {
if (this.format != NativeImage.Format.RGBA) { if (this.format != NativeImage.Format.RGBA) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "getPixelRGBA only works on RGBA images; have %s", this.format)); throw new IllegalArgumentException(String.format(Locale.ROOT, "getPixelRGBA only works on RGBA images; have %s", this.format));
} else if (this.isOutsideBounds(i, j)) { } else if (this.isOutsideBounds(x, y)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "(%s, %s) outside of image bounds (%s, %s)", i, j, this.width, this.height)); throw new IllegalArgumentException(String.format(Locale.ROOT, "(%s, %s) outside of image bounds (%s, %s)", x, y, this.width, this.height));
} else { } else {
this.checkAllocated(); this.checkAllocated();
long l = (i + (long)j * this.width) * 4L; long l = (x + (long)y * this.width) * 4L;
return MemoryUtil.memGetInt(this.pixels + l); return MemoryUtil.memGetInt(this.pixels + l);
} }
} }
public int getPixel(int i, int j) { public int getPixel(int x, int y) {
return ARGB.fromABGR(this.getPixelABGR(i, j)); return ARGB.fromABGR(this.getPixelABGR(x, y));
} }
private void setPixelABGR(int i, int j, int k) { private void setPixelABGR(int x, int y, int color) {
if (this.format != NativeImage.Format.RGBA) { if (this.format != NativeImage.Format.RGBA) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "setPixelRGBA only works on RGBA images; have %s", this.format)); throw new IllegalArgumentException(String.format(Locale.ROOT, "setPixelRGBA only works on RGBA images; have %s", this.format));
} else if (this.isOutsideBounds(i, j)) { } else if (this.isOutsideBounds(x, y)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "(%s, %s) outside of image bounds (%s, %s)", i, j, this.width, this.height)); throw new IllegalArgumentException(String.format(Locale.ROOT, "(%s, %s) outside of image bounds (%s, %s)", x, y, this.width, this.height));
} else { } else {
this.checkAllocated(); this.checkAllocated();
long l = (i + (long)j * this.width) * 4L; long l = (x + (long)y * this.width) * 4L;
MemoryUtil.memPutInt(this.pixels + l, k); MemoryUtil.memPutInt(this.pixels + l, color);
} }
} }
public void setPixel(int i, int j, int k) { public void setPixel(int x, int y, int color) {
this.setPixelABGR(i, j, ARGB.toABGR(k)); this.setPixelABGR(x, y, ARGB.toABGR(color));
} }
public NativeImage mappedCopy(IntUnaryOperator function) { public NativeImage mappedCopy(IntUnaryOperator function) {

View file

@ -290,8 +290,8 @@ public final class Window implements AutoCloseable {
} }
} }
private void onIconify(long l, boolean bl) { private void onIconify(long window, boolean iconified) {
this.iconified = bl; this.iconified = iconified;
} }
public void updateDisplay(@Nullable TracyFrameCapture tracyFrameCapture) { public void updateDisplay(@Nullable TracyFrameCapture tracyFrameCapture) {
@ -371,13 +371,13 @@ public final class Window implements AutoCloseable {
this.setMode(); this.setMode();
} }
private void updateFullscreen(boolean bl, @Nullable TracyFrameCapture tracyFrameCapture) { private void updateFullscreen(boolean vsyncEnabled, @Nullable TracyFrameCapture tracyFrameCapture) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
try { try {
this.setMode(); this.setMode();
this.eventHandler.resizeDisplay(); this.eventHandler.resizeDisplay();
this.updateVsync(bl); this.updateVsync(vsyncEnabled);
this.updateDisplay(tracyFrameCapture); this.updateDisplay(tracyFrameCapture);
} catch (Exception var4) { } catch (Exception var4) {
LOGGER.error("Couldn't toggle fullscreen", (Throwable)var4); LOGGER.error("Couldn't toggle fullscreen", (Throwable)var4);
@ -484,8 +484,8 @@ public final class Window implements AutoCloseable {
InputConstants.updateRawMouseInput(this.window, enableRawMouseMotion); InputConstants.updateRawMouseInput(this.window, enableRawMouseMotion);
} }
public void setWindowCloseCallback(Runnable runnable) { public void setWindowCloseCallback(Runnable windowCloseCallback) {
GLFWWindowCloseCallback gLFWWindowCloseCallback = GLFW.glfwSetWindowCloseCallback(this.window, l -> runnable.run()); GLFWWindowCloseCallback gLFWWindowCloseCallback = GLFW.glfwSetWindowCloseCallback(this.window, l -> windowCloseCallback.run());
if (gLFWWindowCloseCallback != null) { if (gLFWWindowCloseCallback != null) {
gLFWWindowCloseCallback.free(); gLFWWindowCloseCallback.free();
} }

View file

@ -126,13 +126,13 @@ public abstract class GlslPreprocessor {
@Nullable @Nullable
public abstract String applyImport(boolean useFullPath, String directory); public abstract String applyImport(boolean useFullPath, String directory);
public static String injectDefines(String string, ShaderDefines shaderDefines) { public static String injectDefines(String shaderSource, ShaderDefines defines) {
if (shaderDefines.isEmpty()) { if (defines.isEmpty()) {
return string; return shaderSource;
} else { } else {
int i = string.indexOf(10); int i = shaderSource.indexOf(10);
int j = i + 1; int j = i + 1;
return string.substring(0, j) + shaderDefines.asSourceDirectives() + "#line 1 0\n" + string.substring(j); return shaderSource.substring(0, j) + defines.asSourceDirectives() + "#line 1 0\n" + shaderSource.substring(j);
} }
} }

View file

@ -13,8 +13,8 @@ public class CrossFrameResourcePool implements GraphicsResourceAllocator, AutoCl
private final int framesToKeepResource; private final int framesToKeepResource;
private final Deque<CrossFrameResourcePool.ResourceEntry<?>> pool = new ArrayDeque(); private final Deque<CrossFrameResourcePool.ResourceEntry<?>> pool = new ArrayDeque();
public CrossFrameResourcePool(int i) { public CrossFrameResourcePool(int framesToKeepResource) {
this.framesToKeepResource = i; this.framesToKeepResource = framesToKeepResource;
} }
public void endFrame() { public void endFrame() {
@ -30,23 +30,23 @@ public class CrossFrameResourcePool implements GraphicsResourceAllocator, AutoCl
} }
@Override @Override
public <T> T acquire(ResourceDescriptor<T> resourceDescriptor) { public <T> T acquire(ResourceDescriptor<T> descriptor) {
Iterator<? extends CrossFrameResourcePool.ResourceEntry<?>> iterator = this.pool.iterator(); Iterator<? extends CrossFrameResourcePool.ResourceEntry<?>> iterator = this.pool.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
CrossFrameResourcePool.ResourceEntry<?> resourceEntry = (CrossFrameResourcePool.ResourceEntry<?>)iterator.next(); CrossFrameResourcePool.ResourceEntry<?> resourceEntry = (CrossFrameResourcePool.ResourceEntry<?>)iterator.next();
if (resourceEntry.descriptor.equals(resourceDescriptor)) { if (resourceEntry.descriptor.equals(descriptor)) {
iterator.remove(); iterator.remove();
return (T)resourceEntry.value; return (T)resourceEntry.value;
} }
} }
return resourceDescriptor.allocate(); return descriptor.allocate();
} }
@Override @Override
public <T> void release(ResourceDescriptor<T> resourceDescriptor, T object) { public <T> void release(ResourceDescriptor<T> descriptor, T value) {
this.pool.addFirst(new CrossFrameResourcePool.ResourceEntry<>(resourceDescriptor, object, this.framesToKeepResource)); this.pool.addFirst(new CrossFrameResourcePool.ResourceEntry<>(descriptor, value, this.framesToKeepResource));
} }
public void clear() { public void clear() {
@ -70,10 +70,10 @@ public class CrossFrameResourcePool implements GraphicsResourceAllocator, AutoCl
final T value; final T value;
int framesToLive; int framesToLive;
ResourceEntry(ResourceDescriptor<T> resourceDescriptor, T object, int i) { ResourceEntry(ResourceDescriptor<T> descriptor, T value, int framesToLive) {
this.descriptor = resourceDescriptor; this.descriptor = descriptor;
this.value = object; this.value = value;
this.framesToLive = i; this.framesToLive = framesToLive;
} }
public void close() { public void close() {

View file

@ -7,17 +7,17 @@ import net.fabricmc.api.Environment;
public interface GraphicsResourceAllocator { public interface GraphicsResourceAllocator {
GraphicsResourceAllocator UNPOOLED = new GraphicsResourceAllocator() { GraphicsResourceAllocator UNPOOLED = new GraphicsResourceAllocator() {
@Override @Override
public <T> T acquire(ResourceDescriptor<T> resourceDescriptor) { public <T> T acquire(ResourceDescriptor<T> descriptor) {
return resourceDescriptor.allocate(); return descriptor.allocate();
} }
@Override @Override
public <T> void release(ResourceDescriptor<T> resourceDescriptor, T object) { public <T> void release(ResourceDescriptor<T> descriptor, T value) {
resourceDescriptor.free(object); descriptor.free(value);
} }
}; };
<T> T acquire(ResourceDescriptor<T> resourceDescriptor); <T> T acquire(ResourceDescriptor<T> descriptor);
<T> void release(ResourceDescriptor<T> resourceDescriptor, T object); <T> void release(ResourceDescriptor<T> descriptor, T value);
} }

View file

@ -7,5 +7,5 @@ import net.fabricmc.api.Environment;
public interface ResourceDescriptor<T> { public interface ResourceDescriptor<T> {
T allocate(); T allocate();
void free(T object); void free(T target);
} }

View file

@ -16,21 +16,21 @@ public class CompiledShader implements AutoCloseable {
private final ResourceLocation id; private final ResourceLocation id;
private int shaderId; private int shaderId;
private CompiledShader(int i, ResourceLocation resourceLocation) { private CompiledShader(int shaderId, ResourceLocation id) {
this.id = resourceLocation; this.id = id;
this.shaderId = i; this.shaderId = shaderId;
} }
public static CompiledShader compile(ResourceLocation resourceLocation, CompiledShader.Type type, String string) throws ShaderManager.CompilationException { public static CompiledShader compile(ResourceLocation shaderId, CompiledShader.Type type, String source) throws ShaderManager.CompilationException {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
int i = GlStateManager.glCreateShader(type.glType()); int i = GlStateManager.glCreateShader(type.glType());
GlStateManager.glShaderSource(i, string); GlStateManager.glShaderSource(i, source);
GlStateManager.glCompileShader(i); GlStateManager.glCompileShader(i);
if (GlStateManager.glGetShaderi(i, 35713) == 0) { if (GlStateManager.glGetShaderi(i, 35713) == 0) {
String string2 = StringUtils.trim(GlStateManager.glGetShaderInfoLog(i, 32768)); String string = StringUtils.trim(GlStateManager.glGetShaderInfoLog(i, 32768));
throw new ShaderManager.CompilationException("Couldn't compile " + type.getName() + " shader (" + resourceLocation + ") : " + string2); throw new ShaderManager.CompilationException("Couldn't compile " + type.getName() + " shader (" + shaderId + ") : " + string);
} else { } else {
return new CompiledShader(i, resourceLocation); return new CompiledShader(i, shaderId);
} }
} }
@ -62,16 +62,16 @@ public class CompiledShader implements AutoCloseable {
private final String extension; private final String extension;
private final int glType; private final int glType;
private Type(final String string2, final String string3, final int j) { private Type(final String name, final String extension, final int glType) {
this.name = string2; this.name = name;
this.extension = string3; this.extension = extension;
this.glType = j; this.glType = glType;
} }
@Nullable @Nullable
public static CompiledShader.Type byLocation(ResourceLocation resourceLocation) { public static CompiledShader.Type byLocation(ResourceLocation location) {
for (CompiledShader.Type type : TYPES) { for (CompiledShader.Type type : TYPES) {
if (resourceLocation.getPath().endsWith(type.extension)) { if (location.getPath().endsWith(type.extension)) {
return type; return type;
} }
} }

View file

@ -9,7 +9,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.ShaderProgramConfig;
import org.joml.Matrix3f; import org.joml.Matrix3f;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
@ -39,16 +38,16 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
private final FloatBuffer floatValues; private final FloatBuffer floatValues;
private final String name; private final String name;
public Uniform(String string, int i, int j) { public Uniform(String name, int type, int count) {
this.name = string; this.name = name;
this.count = j; this.count = count;
this.type = i; this.type = type;
if (i <= 3) { if (type <= 3) {
this.intValues = MemoryUtil.memAllocInt(j); this.intValues = MemoryUtil.memAllocInt(count);
this.floatValues = null; this.floatValues = null;
} else { } else {
this.intValues = null; this.intValues = null;
this.floatValues = MemoryUtil.memAllocFloat(j); this.floatValues = MemoryUtil.memAllocFloat(count);
} }
this.location = -1; this.location = -1;
@ -63,17 +62,17 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
RenderSystem.glUniform1i(location, value); RenderSystem.glUniform1i(location, value);
} }
public void setFromConfig(ShaderProgramConfig.Uniform uniform) { public void setFromConfig(net.minecraft.client.renderer.ShaderProgramConfig.Uniform uniform) {
this.setFromConfig(uniform.values(), uniform.count()); this.setFromConfig(uniform.values(), uniform.count());
} }
public void setFromConfig(List<Float> list, int i) { public void setFromConfig(List<Float> values, int count) {
float[] fs = new float[Math.max(i, 16)]; float[] fs = new float[Math.max(count, 16)];
if (list.size() == 1) { if (values.size() == 1) {
Arrays.fill(fs, (Float)list.getFirst()); Arrays.fill(fs, (Float)values.getFirst());
} else { } else {
for (int j = 0; j < list.size(); j++) { for (int i = 0; i < values.size(); i++) {
fs[j] = (Float)list.get(j); fs[i] = (Float)values.get(i);
} }
} }
@ -82,7 +81,7 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
} else if (this.type <= 7) { } else if (this.type <= 7) {
this.setSafe(fs[0], fs[1], fs[2], fs[3]); this.setSafe(fs[0], fs[1], fs[2], fs[3]);
} else { } else {
this.set(Arrays.copyOfRange(fs, 0, i)); this.set(Arrays.copyOfRange(fs, 0, count));
} }
} }

View file

@ -1,5 +1,6 @@
package com.mojang.blaze3d.vertex; package com.mojang.blaze3d.vertex;
import com.mojang.blaze3d.vertex.ByteBufferBuilder.Result;
import com.mojang.blaze3d.vertex.MeshData.DrawState; import com.mojang.blaze3d.vertex.MeshData.DrawState;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -75,7 +76,7 @@ public class BufferBuilder implements VertexConsumer {
if (this.vertices == 0) { if (this.vertices == 0) {
return null; return null;
} else { } else {
ByteBufferBuilder.Result result = this.buffer.build(); Result result = this.buffer.build();
if (result == null) { if (result == null) {
return null; return null;
} else { } else {

View file

@ -29,8 +29,8 @@ public class PoseStack {
pose.pose.translate(x, y, z); pose.pose.translate(x, y, z);
} }
public void translate(Vec3 vec3) { public void translate(Vec3 vector) {
this.translate(vec3.x, vec3.y, vec3.z); this.translate(vector.x, vector.y, vector.z);
} }
public void scale(float x, float y, float z) { public void scale(float x, float y, float z) {

View file

@ -5,6 +5,8 @@ import com.mojang.blaze3d.buffers.BufferUsage;
import com.mojang.blaze3d.buffers.GpuBuffer; import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.systems.RenderSystem.AutoStorageIndexBuffer;
import com.mojang.blaze3d.vertex.ByteBufferBuilder.Result;
import com.mojang.blaze3d.vertex.MeshData.DrawState; import com.mojang.blaze3d.vertex.MeshData.DrawState;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -24,15 +26,15 @@ public class VertexBuffer implements AutoCloseable {
@Nullable @Nullable
private VertexFormat format; private VertexFormat format;
@Nullable @Nullable
private RenderSystem.AutoStorageIndexBuffer sequentialIndices; private AutoStorageIndexBuffer sequentialIndices;
private VertexFormat.IndexType indexType; private VertexFormat.IndexType indexType;
private int indexCount; private int indexCount;
private VertexFormat.Mode mode; private VertexFormat.Mode mode;
public VertexBuffer(BufferUsage bufferUsage) { public VertexBuffer(BufferUsage usage) {
this.usage = bufferUsage; this.usage = usage;
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
this.vertexBuffer = new GpuBuffer(BufferType.VERTICES, bufferUsage, 0); this.vertexBuffer = new GpuBuffer(BufferType.VERTICES, usage, 0);
this.arrayObjectId = GlStateManager._glGenVertexArrays(); this.arrayObjectId = GlStateManager._glGenVertexArrays();
} }
@ -76,8 +78,8 @@ public class VertexBuffer implements AutoCloseable {
} }
} }
public void uploadIndexBuffer(ByteBufferBuilder.Result result) { public void uploadIndexBuffer(Result result) {
ByteBufferBuilder.Result var2 = result; Result var2 = result;
label46: { label46: {
try { try {
@ -141,7 +143,7 @@ public class VertexBuffer implements AutoCloseable {
} }
@Nullable @Nullable
private RenderSystem.AutoStorageIndexBuffer uploadIndexBuffer(DrawState drawState, @Nullable ByteBuffer buffer) { private AutoStorageIndexBuffer uploadIndexBuffer(DrawState drawState, @Nullable ByteBuffer buffer) {
if (buffer != null) { if (buffer != null) {
if (this.indexBuffer != null) { if (this.indexBuffer != null) {
this.indexBuffer.close(); this.indexBuffer.close();
@ -150,7 +152,7 @@ public class VertexBuffer implements AutoCloseable {
this.indexBuffer = new GpuBuffer(BufferType.INDICES, this.usage, buffer); this.indexBuffer = new GpuBuffer(BufferType.INDICES, this.usage, buffer);
return null; return null;
} else { } else {
RenderSystem.AutoStorageIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(drawState.mode()); AutoStorageIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(drawState.mode());
if (autoStorageIndexBuffer != this.sequentialIndices || !autoStorageIndexBuffer.hasStorage(drawState.indexCount())) { if (autoStorageIndexBuffer != this.sequentialIndices || !autoStorageIndexBuffer.hasStorage(drawState.indexCount())) {
autoStorageIndexBuffer.bind(drawState.indexCount()); autoStorageIndexBuffer.bind(drawState.indexCount());
} }
@ -174,17 +176,17 @@ public class VertexBuffer implements AutoCloseable {
} }
private VertexFormat.IndexType getIndexType() { private VertexFormat.IndexType getIndexType() {
RenderSystem.AutoStorageIndexBuffer autoStorageIndexBuffer = this.sequentialIndices; AutoStorageIndexBuffer autoStorageIndexBuffer = this.sequentialIndices;
return autoStorageIndexBuffer != null ? autoStorageIndexBuffer.type() : this.indexType; return autoStorageIndexBuffer != null ? autoStorageIndexBuffer.type() : this.indexType;
} }
public void drawWithShader(Matrix4f matrix4f, Matrix4f matrix4f2, @Nullable CompiledShaderProgram compiledShaderProgram) { public void drawWithShader(Matrix4f frustumMatrix, Matrix4f projectionMatrix, @Nullable CompiledShaderProgram shader) {
if (compiledShaderProgram != null) { if (shader != null) {
RenderSystem.assertOnRenderThread(); RenderSystem.assertOnRenderThread();
compiledShaderProgram.setDefaultUniforms(this.mode, matrix4f, matrix4f2, Minecraft.getInstance().getWindow()); shader.setDefaultUniforms(this.mode, frustumMatrix, projectionMatrix, Minecraft.getInstance().getWindow());
compiledShaderProgram.apply(); shader.apply();
this.draw(); this.draw();
compiledShaderProgram.clear(); shader.clear();
} }
} }

View file

@ -149,7 +149,7 @@ public interface VertexConsumer {
return this.setNormal(vector3f.x(), vector3f.y(), vector3f.z()); return this.setNormal(vector3f.x(), vector3f.y(), vector3f.z());
} }
default VertexConsumer setNormal(PoseStack.Pose pose, Vector3f vector3f) { default VertexConsumer setNormal(PoseStack.Pose pose, Vector3f normalVector) {
return this.setNormal(pose, vector3f.x(), vector3f.y(), vector3f.z()); return this.setNormal(pose, normalVector.x(), normalVector.y(), normalVector.z());
} }
} }

View file

@ -41,12 +41,12 @@ public class VertexFormat {
return new VertexFormat.Builder(); return new VertexFormat.Builder();
} }
public void bindAttributes(int i) { public void bindAttributes(int program) {
int j = 0; int i = 0;
for (String string : this.getElementAttributeNames()) { for (String string : this.getElementAttributeNames()) {
GlStateManager._glBindAttribLocation(i, j, string); GlStateManager._glBindAttribLocation(program, i, string);
j++; i++;
} }
} }

View file

@ -35,9 +35,9 @@ public class MatrixUtil {
); );
} }
private static GivensParameters approxGivensQuat(float f, float g, float h) { private static GivensParameters approxGivensQuat(float topCorner, float oppositeDiagonalAverage, float bottomCorner) {
float i = 2.0F * (f - h); float f = 2.0F * (topCorner - bottomCorner);
return G * g * g < i * i ? GivensParameters.fromUnnormalized(g, i) : PI_4; return G * oppositeDiagonalAverage * oppositeDiagonalAverage < f * f ? GivensParameters.fromUnnormalized(oppositeDiagonalAverage, f) : PI_4;
} }
private static GivensParameters qrGivensQuat(float input1, float input2) { private static GivensParameters qrGivensQuat(float input1, float input2) {

View file

@ -5,6 +5,7 @@ import com.google.common.util.concurrent.RateLimiter;
import com.mojang.authlib.yggdrasil.ProfileResult; import com.mojang.authlib.yggdrasil.ProfileResult;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import com.mojang.realmsclient.RealmsAvailability.Result;
import com.mojang.realmsclient.client.Ping; import com.mojang.realmsclient.client.Ping;
import com.mojang.realmsclient.client.RealmsClient; import com.mojang.realmsclient.client.RealmsClient;
import com.mojang.realmsclient.dto.PingResult; import com.mojang.realmsclient.dto.PingResult;
@ -59,10 +60,12 @@ import net.minecraft.client.gui.components.MultiLineTextWidget;
import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.components.PlayerFaceRenderer; import net.minecraft.client.gui.components.PlayerFaceRenderer;
import net.minecraft.client.gui.components.PopupScreen; import net.minecraft.client.gui.components.PopupScreen;
import net.minecraft.client.gui.components.SpriteIconButton;
import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.components.WidgetSprites; import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.components.WidgetTooltipHolder; import net.minecraft.client.gui.components.WidgetTooltipHolder;
import net.minecraft.client.gui.components.Button.OnPress;
import net.minecraft.client.gui.components.PopupScreen.Builder;
import net.minecraft.client.gui.components.SpriteIconButton.CenteredIcon;
import net.minecraft.client.gui.layouts.FrameLayout; import net.minecraft.client.gui.layouts.FrameLayout;
import net.minecraft.client.gui.layouts.GridLayout; import net.minecraft.client.gui.layouts.GridLayout;
import net.minecraft.client.gui.layouts.HeaderAndFooterLayout; import net.minecraft.client.gui.layouts.HeaderAndFooterLayout;
@ -141,7 +144,7 @@ public class RealmsMainScreen extends RealmsScreen {
private static final int ITEM_HEIGHT = 36; private static final int ITEM_HEIGHT = 36;
private static final boolean SNAPSHOT = !SharedConstants.getCurrentVersion().isStable(); private static final boolean SNAPSHOT = !SharedConstants.getCurrentVersion().isStable();
private static boolean snapshotToggle = SNAPSHOT; private static boolean snapshotToggle = SNAPSHOT;
private final CompletableFuture<RealmsAvailability.Result> availability = RealmsAvailability.get(); private final CompletableFuture<Result> availability = RealmsAvailability.get();
@Nullable @Nullable
private Subscription dataSubscription; private Subscription dataSubscription;
private final Set<UUID> handledSeenNotifications = new HashSet(); private final Set<UUID> handledSeenNotifications = new HashSet();
@ -627,7 +630,7 @@ public class RealmsMainScreen extends RealmsScreen {
case INCOMPATIBLE: case INCOMPATIBLE:
Minecraft.getInstance() Minecraft.getInstance()
.setScreen( .setScreen(
new PopupScreen.Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE) new Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
.setMessage( .setMessage(
Component.translatable( Component.translatable(
"mco.compatibility.incompatible.series.popup.message", "mco.compatibility.incompatible.series.popup.message",
@ -642,7 +645,7 @@ public class RealmsMainScreen extends RealmsScreen {
case RELEASE_TYPE_INCOMPATIBLE: case RELEASE_TYPE_INCOMPATIBLE:
Minecraft.getInstance() Minecraft.getInstance()
.setScreen( .setScreen(
new PopupScreen.Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE) new Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
.setMessage(INCOMPATIBLE_RELEASE_TYPE_POPUP_MESSAGE) .setMessage(INCOMPATIBLE_RELEASE_TYPE_POPUP_MESSAGE)
.addButton(CommonComponents.GUI_BACK, PopupScreen::onClose) .addButton(CommonComponents.GUI_BACK, PopupScreen::onClose)
.build() .build()
@ -652,7 +655,7 @@ public class RealmsMainScreen extends RealmsScreen {
} }
private static void confirmToPlay(RealmsServer realmsServer, Screen lastScreen, Component title, Component message, Component confirmButton) { private static void confirmToPlay(RealmsServer realmsServer, Screen lastScreen, Component title, Component message, Component confirmButton) {
Minecraft.getInstance().setScreen(new PopupScreen.Builder(lastScreen, title).setMessage(message).addButton(confirmButton, popupScreen -> { Minecraft.getInstance().setScreen(new Builder(lastScreen, title).setMessage(message).addButton(confirmButton, popupScreen -> {
Minecraft.getInstance().setScreen(new RealmsLongRunningMcoTaskScreen(lastScreen, new GetServerDetailsTask(lastScreen, realmsServer))); Minecraft.getInstance().setScreen(new RealmsLongRunningMcoTaskScreen(lastScreen, new GetServerDetailsTask(lastScreen, realmsServer)));
refreshServerList(); refreshServerList();
}).addButton(CommonComponents.GUI_CANCEL, PopupScreen::onClose).build()); }).addButton(CommonComponents.GUI_CANCEL, PopupScreen::onClose).build());
@ -677,8 +680,8 @@ public class RealmsMainScreen extends RealmsScreen {
return (Component)(StringUtils.isBlank(version) ? CommonComponents.EMPTY : Component.literal(version).withColor(color)); return (Component)(StringUtils.isBlank(version) ? CommonComponents.EMPTY : Component.literal(version).withColor(color));
} }
public static Component getGameModeComponent(int i, boolean bl) { public static Component getGameModeComponent(int gamemode, boolean hardcore) {
return (Component)(bl ? Component.translatable("gameMode.hardcore").withColor(-65536) : GameType.byId(i).getLongDisplayName()); return (Component)(hardcore ? Component.translatable("gameMode.hardcore").withColor(-65536) : GameType.byId(gamemode).getLongDisplayName());
} }
static boolean isSelfOwnedServer(RealmsServer server) { static boolean isSelfOwnedServer(RealmsServer server) {
@ -745,7 +748,7 @@ public class RealmsMainScreen extends RealmsScreen {
RealmsMainScreen.this.minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); RealmsMainScreen.this.minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
RealmsMainScreen.this.minecraft RealmsMainScreen.this.minecraft
.setScreen( .setScreen(
new PopupScreen.Builder(RealmsMainScreen.this, Component.translatable("mco.snapshot.createSnapshotPopup.title")) new Builder(RealmsMainScreen.this, Component.translatable("mco.snapshot.createSnapshotPopup.title"))
.setMessage(Component.translatable("mco.snapshot.createSnapshotPopup.text")) .setMessage(Component.translatable("mco.snapshot.createSnapshotPopup.text"))
.addButton( .addButton(
Component.translatable("mco.selectServer.create"), Component.translatable("mco.selectServer.create"),
@ -810,7 +813,7 @@ public class RealmsMainScreen extends RealmsScreen {
ResourceLocation.withDefaultNamespace("widget/cross_button"), ResourceLocation.withDefaultNamespace("widget/cross_button_highlighted") ResourceLocation.withDefaultNamespace("widget/cross_button"), ResourceLocation.withDefaultNamespace("widget/cross_button_highlighted")
); );
protected CrossButton(Button.OnPress onPress, Component message) { protected CrossButton(OnPress onPress, Component message) {
super(0, 0, 14, 14, SPRITES, onPress); super(0, 0, 14, 14, SPRITES, onPress);
this.setTooltip(Tooltip.create(message)); this.setTooltip(Tooltip.create(message));
} }
@ -902,26 +905,26 @@ public class RealmsMainScreen extends RealmsScreen {
return left + width - RealmsMainScreen.this.font.width(versionComponent) - 20; return left + width - RealmsMainScreen.this.font.width(versionComponent) - 20;
} }
protected int gameModeTextX(int i, int j, Component component) { protected int gameModeTextX(int left, int width, Component component) {
return i + j - RealmsMainScreen.this.font.width(component) - 20; return left + width - RealmsMainScreen.this.font.width(component) - 20;
} }
protected int renderGameMode(RealmsServer realmsServer, GuiGraphics guiGraphics, int i, int j, int k) { protected int renderGameMode(RealmsServer server, GuiGraphics guiGraphics, int left, int width, int firstLineY) {
boolean bl = realmsServer.isHardcore; boolean bl = server.isHardcore;
int l = realmsServer.gameMode; int i = server.gameMode;
int m = i; int j = left;
if (GameType.isValidId(l)) { if (GameType.isValidId(i)) {
Component component = RealmsMainScreen.getGameModeComponent(l, bl); Component component = RealmsMainScreen.getGameModeComponent(i, bl);
m = this.gameModeTextX(i, j, component); j = this.gameModeTextX(left, width, component);
guiGraphics.drawString(RealmsMainScreen.this.font, component, m, this.secondLineY(k), -8355712, false); guiGraphics.drawString(RealmsMainScreen.this.font, component, j, this.secondLineY(firstLineY), -8355712, false);
} }
if (bl) { if (bl) {
m -= 10; j -= 10;
guiGraphics.blitSprite(RenderType::guiTextured, RealmsMainScreen.HARDCORE_MODE_SPRITE, m, this.secondLineY(k), 8, 8); guiGraphics.blitSprite(RenderType::guiTextured, RealmsMainScreen.HARDCORE_MODE_SPRITE, j, this.secondLineY(firstLineY), 8, 8);
} }
return m; return j;
} }
protected int firstLineY(int top) { protected int firstLineY(int top) {
@ -953,7 +956,7 @@ public class RealmsMainScreen extends RealmsScreen {
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
static class NotificationButton extends SpriteIconButton.CenteredIcon { static class NotificationButton extends CenteredIcon {
private static final ResourceLocation[] NOTIFICATION_ICONS = new ResourceLocation[]{ private static final ResourceLocation[] NOTIFICATION_ICONS = new ResourceLocation[]{
ResourceLocation.withDefaultNamespace("notification/1"), ResourceLocation.withDefaultNamespace("notification/1"),
ResourceLocation.withDefaultNamespace("notification/2"), ResourceLocation.withDefaultNamespace("notification/2"),
@ -967,7 +970,7 @@ public class RealmsMainScreen extends RealmsScreen {
private static final int SPRITE_SIZE = 14; private static final int SPRITE_SIZE = 14;
private int notificationCount; private int notificationCount;
public NotificationButton(Component message, ResourceLocation sprite, Button.OnPress onPress) { public NotificationButton(Component message, ResourceLocation sprite, OnPress onPress) {
super(20, 20, message, 14, 14, sprite, onPress, null); super(20, 20, message, 14, 14, sprite, onPress, null);
} }
@ -1135,8 +1138,8 @@ public class RealmsMainScreen extends RealmsScreen {
super(Minecraft.getInstance(), RealmsMainScreen.this.width, RealmsMainScreen.this.height, 0, 36); super(Minecraft.getInstance(), RealmsMainScreen.this.width, RealmsMainScreen.this.height, 0, 36);
} }
public void setSelected(@Nullable RealmsMainScreen.Entry entry) { public void setSelected(@Nullable RealmsMainScreen.Entry selected) {
super.setSelected(entry); super.setSelected(selected);
RealmsMainScreen.this.updateButtonStates(); RealmsMainScreen.this.updateButtonStates();
} }
@ -1145,55 +1148,55 @@ public class RealmsMainScreen extends RealmsScreen {
return 300; return 300;
} }
void refreshEntries(RealmsMainScreen realmsMainScreen, @Nullable RealmsServer realmsServer) { void refreshEntries(RealmsMainScreen screen, @Nullable RealmsServer server) {
this.clearEntries(); this.clearEntries();
for (RealmsNotification realmsNotification : RealmsMainScreen.this.notifications) { for (RealmsNotification realmsNotification : RealmsMainScreen.this.notifications) {
if (realmsNotification instanceof VisitUrl visitUrl) { if (realmsNotification instanceof VisitUrl visitUrl) {
this.addEntriesForNotification(visitUrl, realmsMainScreen); this.addEntriesForNotification(visitUrl, screen);
RealmsMainScreen.this.markNotificationsAsSeen(List.of(realmsNotification)); RealmsMainScreen.this.markNotificationsAsSeen(List.of(realmsNotification));
break; break;
} }
} }
this.refreshServerEntries(realmsServer); this.refreshServerEntries(server);
} }
private void refreshServerEntries(@Nullable RealmsServer realmsServer) { private void refreshServerEntries(@Nullable RealmsServer server) {
for (RealmsServer realmsServer2 : RealmsMainScreen.this.availableSnapshotServers) { for (RealmsServer realmsServer : RealmsMainScreen.this.availableSnapshotServers) {
this.addEntry(RealmsMainScreen.this.new AvailableSnapshotEntry(realmsServer2)); this.addEntry(RealmsMainScreen.this.new AvailableSnapshotEntry(realmsServer));
} }
for (RealmsServer realmsServer2 : RealmsMainScreen.this.serverList) { for (RealmsServer realmsServer : RealmsMainScreen.this.serverList) {
RealmsMainScreen.Entry entry; RealmsMainScreen.Entry entry;
if (RealmsMainScreen.isSnapshot() && !realmsServer2.isSnapshotRealm()) { if (RealmsMainScreen.isSnapshot() && !realmsServer.isSnapshotRealm()) {
if (realmsServer2.state == RealmsServer.State.UNINITIALIZED) { if (realmsServer.state == RealmsServer.State.UNINITIALIZED) {
continue; continue;
} }
entry = RealmsMainScreen.this.new ParentEntry(realmsServer2); entry = RealmsMainScreen.this.new ParentEntry(realmsServer);
} else { } else {
entry = RealmsMainScreen.this.new ServerEntry(realmsServer2); entry = RealmsMainScreen.this.new ServerEntry(realmsServer);
} }
this.addEntry(entry); this.addEntry(entry);
if (realmsServer != null && realmsServer.id == realmsServer2.id) { if (server != null && server.id == realmsServer.id) {
this.setSelected(entry); this.setSelected(entry);
} }
} }
} }
private void addEntriesForNotification(VisitUrl visitUrl, RealmsMainScreen realmsMainScreen) { private void addEntriesForNotification(VisitUrl url, RealmsMainScreen mainScreen) {
Component component = visitUrl.getMessage(); Component component = url.getMessage();
int i = RealmsMainScreen.this.font.wordWrapHeight(component, 216); int i = RealmsMainScreen.this.font.wordWrapHeight(component, 216);
int j = Mth.positiveCeilDiv(i + 7, 36) - 1; int j = Mth.positiveCeilDiv(i + 7, 36) - 1;
this.addEntry(RealmsMainScreen.this.new NotificationMessageEntry(component, j + 2, visitUrl)); this.addEntry(RealmsMainScreen.this.new NotificationMessageEntry(component, j + 2, url));
for (int k = 0; k < j; k++) { for (int k = 0; k < j; k++) {
this.addEntry(RealmsMainScreen.this.new EmptyEntry()); this.addEntry(RealmsMainScreen.this.new EmptyEntry());
} }
this.addEntry(RealmsMainScreen.this.new ButtonEntry(visitUrl.buildOpenLinkButton(realmsMainScreen))); this.addEntry(RealmsMainScreen.this.new ButtonEntry(url.buildOpenLinkButton(mainScreen)));
} }
} }
@ -1251,18 +1254,18 @@ public class RealmsMainScreen extends RealmsScreen {
} }
} }
private void renderSecondLine(GuiGraphics guiGraphics, int i, int j, int k) { private void renderSecondLine(GuiGraphics guiGraphics, int top, int left, int width) {
int l = this.textX(j); int i = this.textX(left);
int m = this.firstLineY(i); int j = this.firstLineY(top);
int n = this.secondLineY(m); int k = this.secondLineY(j);
String string = this.serverData.getMinigameName(); String string = this.serverData.getMinigameName();
boolean bl = this.serverData.isMinigameActive(); boolean bl = this.serverData.isMinigameActive();
if (bl && string != null) { if (bl && string != null) {
Component component = Component.literal(string).withStyle(ChatFormatting.GRAY); Component component = Component.literal(string).withStyle(ChatFormatting.GRAY);
guiGraphics.drawString(RealmsMainScreen.this.font, Component.translatable("mco.selectServer.minigameName", component).withColor(-171), l, n, -1, false); guiGraphics.drawString(RealmsMainScreen.this.font, Component.translatable("mco.selectServer.minigameName", component).withColor(-171), i, k, -1, false);
} else { } else {
int o = this.renderGameMode(this.serverData, guiGraphics, j, k, m); int l = this.renderGameMode(this.serverData, guiGraphics, left, width, j);
this.renderClampedString(guiGraphics, this.serverData.getDescription(), l, this.secondLineY(m), o, -8355712); this.renderClampedString(guiGraphics, this.serverData.getDescription(), i, this.secondLineY(j), l, -8355712);
} }
} }

View file

@ -6,6 +6,7 @@ import com.mojang.logging.LogUtils;
import com.mojang.realmsclient.client.worldupload.RealmsUploadCanceledException; import com.mojang.realmsclient.client.worldupload.RealmsUploadCanceledException;
import com.mojang.realmsclient.dto.UploadInfo; import com.mojang.realmsclient.dto.UploadInfo;
import com.mojang.realmsclient.gui.screens.UploadResult; import com.mojang.realmsclient.gui.screens.UploadResult;
import com.mojang.realmsclient.gui.screens.UploadResult.Builder;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -69,12 +70,12 @@ public class FileUpload {
public UploadResult upload() { public UploadResult upload() {
if (this.uploadTask != null) { if (this.uploadTask != null) {
return new UploadResult.Builder().build(); return new Builder().build();
} else { } else {
this.uploadTask = CompletableFuture.supplyAsync(() -> this.requestUpload(0), Util.backgroundExecutor()); this.uploadTask = CompletableFuture.supplyAsync(() -> this.requestUpload(0), Util.backgroundExecutor());
if (this.cancelled.get()) { if (this.cancelled.get()) {
this.cancel(); this.cancel();
return new UploadResult.Builder().build(); return new Builder().build();
} else { } else {
return (UploadResult)this.uploadTask.join(); return (UploadResult)this.uploadTask.join();
} }
@ -89,7 +90,7 @@ public class FileUpload {
* @param retries The number of times this upload has already been attempted * @param retries The number of times this upload has already been attempted
*/ */
private UploadResult requestUpload(int retries) { private UploadResult requestUpload(int retries) {
UploadResult.Builder builder = new UploadResult.Builder(); Builder builder = new Builder();
if (this.cancelled.get()) { if (this.cancelled.get()) {
return builder.build(); return builder.build();
} else { } else {
@ -155,7 +156,7 @@ public class FileUpload {
post.setEntity(customInputStreamEntity); post.setEntity(customInputStreamEntity);
} }
private void handleResponse(HttpResponse response, UploadResult.Builder uploadResult) throws IOException { private void handleResponse(HttpResponse response, Builder uploadResult) throws IOException {
int i = response.getStatusLine().getStatusCode(); int i = response.getStatusLine().getStatusCode();
if (i == 401) { if (i == 401) {
LOGGER.debug("Realms server returned 401: {}", response.getFirstHeader("WWW-Authenticate")); LOGGER.debug("Realms server returned 401: {}", response.getFirstHeader("WWW-Authenticate"));
@ -199,10 +200,10 @@ public class FileUpload {
private final InputStream content; private final InputStream content;
private final UploadStatus uploadStatus; private final UploadStatus uploadStatus;
public CustomInputStreamEntity(final InputStream inputStream, final long l, final UploadStatus uploadStatus) { public CustomInputStreamEntity(final InputStream content, final long length, final UploadStatus uploadStatus) {
super(inputStream); super(content);
this.content = inputStream; this.content = content;
this.length = l; this.length = length;
this.uploadStatus = uploadStatus; this.uploadStatus = uploadStatus;
} }

View file

@ -345,12 +345,12 @@ public class RealmsClient {
} }
@Nullable @Nullable
public UploadInfo requestUploadInfo(long l) throws RealmsServiceException { public UploadInfo requestUploadInfo(long worldId) throws RealmsServiceException {
String string = this.url("worlds" + "/$WORLD_ID/backups/upload".replace("$WORLD_ID", String.valueOf(l))); String string = this.url("worlds" + "/$WORLD_ID/backups/upload".replace("$WORLD_ID", String.valueOf(worldId)));
String string2 = UploadTokenCache.get(l); String string2 = UploadTokenCache.get(worldId);
UploadInfo uploadInfo = UploadInfo.parse(this.execute(Request.put(string, UploadInfo.createRequest(string2)))); UploadInfo uploadInfo = UploadInfo.parse(this.execute(Request.put(string, UploadInfo.createRequest(string2))));
if (uploadInfo != null) { if (uploadInfo != null) {
UploadTokenCache.put(l, uploadInfo.getToken()); UploadTokenCache.put(worldId, uploadInfo.getToken());
} }
return uploadInfo; return uploadInfo;

View file

@ -12,8 +12,8 @@ public class UploadStatus {
private long previousBytesWritten; private long previousBytesWritten;
private long bytesPerSecond; private long bytesPerSecond;
public void setTotalBytes(long l) { public void setTotalBytes(long totalBytes) {
this.totalBytes = l; this.totalBytes = totalBytes;
} }
public long getTotalBytes() { public long getTotalBytes() {
@ -24,8 +24,8 @@ public class UploadStatus {
return this.bytesWritten; return this.bytesWritten;
} }
public void onWrite(long l) { public void onWrite(long bytes) {
this.bytesWritten += l; this.bytesWritten += bytes;
} }
public boolean uploadStarted() { public boolean uploadStarted() {

View file

@ -33,18 +33,18 @@ public class RealmsCreateWorldFlow {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public static void createWorld( public static void createWorld(
Minecraft minecraft, Screen screen, Screen screen2, int i, RealmsServer realmsServer, @Nullable RealmCreationTask realmCreationTask Minecraft minecraft, Screen lastScreen, Screen resetWorldScreen, int slot, RealmsServer server, @Nullable RealmCreationTask realmCreationTask
) { ) {
CreateWorldScreen.openFresh( CreateWorldScreen.openFresh(
minecraft, minecraft,
screen, lastScreen,
(createWorldScreen, layeredRegistryAccess, primaryLevelData, path) -> { (createWorldScreen, layeredRegistryAccess, primaryLevelData, path) -> {
Path path2; Path path2;
try { try {
path2 = createTemporaryWorldFolder(layeredRegistryAccess, primaryLevelData, path); path2 = createTemporaryWorldFolder(layeredRegistryAccess, primaryLevelData, path);
} catch (IOException var13) { } catch (IOException var13) {
LOGGER.warn("Failed to create temporary world folder."); LOGGER.warn("Failed to create temporary world folder.");
minecraft.setScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), screen2)); minecraft.setScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), resetWorldScreen));
return true; return true;
} }
@ -52,7 +52,7 @@ public class RealmsCreateWorldFlow {
primaryLevelData.getLevelSettings(), SharedConstants.getCurrentVersion().getName() primaryLevelData.getLevelSettings(), SharedConstants.getCurrentVersion().getName()
); );
RealmsWorldUpload realmsWorldUpload = new RealmsWorldUpload( RealmsWorldUpload realmsWorldUpload = new RealmsWorldUpload(
path2, realmsWorldOptions, minecraft.getUser(), realmsServer.id, i, RealmsWorldUploadStatusTracker.noOp() path2, realmsWorldOptions, minecraft.getUser(), server.id, slot, RealmsWorldUploadStatusTracker.noOp()
); );
minecraft.forceSetScreen( minecraft.forceSetScreen(
new AlertScreen(realmsWorldUpload::cancel, Component.translatable("mco.create.world.reset.title"), Component.empty(), CommonComponents.GUI_CANCEL, false) new AlertScreen(realmsWorldUpload::cancel, Component.translatable("mco.create.world.reset.title"), Component.empty(), CommonComponents.GUI_CANCEL, false)
@ -68,7 +68,7 @@ public class RealmsCreateWorldFlow {
} }
if (throwable instanceof RealmsUploadCanceledException) { if (throwable instanceof RealmsUploadCanceledException) {
minecraft.forceSetScreen(screen2); minecraft.forceSetScreen(resetWorldScreen);
} else { } else {
if (throwable instanceof RealmsUploadFailedException realmsUploadFailedException) { if (throwable instanceof RealmsUploadFailedException realmsUploadFailedException) {
LOGGER.warn("Failed to create realms world {}", realmsUploadFailedException.getStatusMessage()); LOGGER.warn("Failed to create realms world {}", realmsUploadFailedException.getStatusMessage());
@ -76,17 +76,17 @@ public class RealmsCreateWorldFlow {
LOGGER.warn("Failed to create realms world {}", throwable.getMessage()); LOGGER.warn("Failed to create realms world {}", throwable.getMessage());
} }
minecraft.forceSetScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), screen2)); minecraft.forceSetScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), resetWorldScreen));
} }
} else { } else {
if (screen instanceof RealmsConfigureWorldScreen realmsConfigureWorldScreen) { if (lastScreen instanceof RealmsConfigureWorldScreen realmsConfigureWorldScreen) {
realmsConfigureWorldScreen.fetchServerData(realmsServer.id); realmsConfigureWorldScreen.fetchServerData(server.id);
} }
if (realmCreationTask != null) { if (realmCreationTask != null) {
RealmsMainScreen.play(realmsServer, screen, true); RealmsMainScreen.play(server, lastScreen, true);
} else { } else {
minecraft.forceSetScreen(screen); minecraft.forceSetScreen(lastScreen);
} }
RealmsMainScreen.refreshServerList(); RealmsMainScreen.refreshServerList();
@ -99,19 +99,17 @@ public class RealmsCreateWorldFlow {
); );
} }
private static Path createTemporaryWorldFolder( private static Path createTemporaryWorldFolder(LayeredRegistryAccess<RegistryLayer> registryAccess, PrimaryLevelData levelData, @Nullable Path tempDatapackDir) throws IOException {
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess, PrimaryLevelData primaryLevelData, @Nullable Path path Path path = Files.createTempDirectory("minecraft_realms_world_upload");
) throws IOException { if (tempDatapackDir != null) {
Path path2 = Files.createTempDirectory("minecraft_realms_world_upload"); Files.move(tempDatapackDir, path.resolve("datapacks"));
if (path != null) {
Files.move(path, path2.resolve("datapacks"));
} }
CompoundTag compoundTag = primaryLevelData.createTag(layeredRegistryAccess.compositeAccess(), null); CompoundTag compoundTag = levelData.createTag(registryAccess.compositeAccess(), null);
CompoundTag compoundTag2 = new CompoundTag(); CompoundTag compoundTag2 = new CompoundTag();
compoundTag2.put("Data", compoundTag); compoundTag2.put("Data", compoundTag);
Path path3 = Files.createFile(path2.resolve("level.dat")); Path path2 = Files.createFile(path.resolve("level.dat"));
NbtIo.writeCompressed(compoundTag2, path3); NbtIo.writeCompressed(compoundTag2, path2);
return path2; return path;
} }
} }

View file

@ -8,12 +8,12 @@ import net.minecraft.network.chat.Component;
public class RealmsUploadFailedException extends RealmsUploadException { public class RealmsUploadFailedException extends RealmsUploadException {
private final Component errorMessage; private final Component errorMessage;
public RealmsUploadFailedException(Component component) { public RealmsUploadFailedException(Component errorMessage) {
this.errorMessage = component; this.errorMessage = errorMessage;
} }
public RealmsUploadFailedException(String string) { public RealmsUploadFailedException(String errorMessage) {
this(Component.literal(string)); this(Component.literal(errorMessage));
} }
@Override @Override

View file

@ -9,8 +9,8 @@ import net.minecraft.network.chat.Component;
public class RealmsUploadTooLargeException extends RealmsUploadException { public class RealmsUploadTooLargeException extends RealmsUploadException {
final long sizeLimit; final long sizeLimit;
public RealmsUploadTooLargeException(long l) { public RealmsUploadTooLargeException(long sizeLimit) {
this.sizeLimit = l; this.sizeLimit = sizeLimit;
} }
@Override @Override

View file

@ -20,13 +20,13 @@ public class RealmsUploadWorldPacker {
private final BooleanSupplier isCanceled; private final BooleanSupplier isCanceled;
private final Path directoryToPack; private final Path directoryToPack;
public static File pack(Path path, BooleanSupplier booleanSupplier) throws IOException { public static File pack(Path directoryToPack, BooleanSupplier isCanceled) throws IOException {
return new RealmsUploadWorldPacker(path, booleanSupplier).tarGzipArchive(); return new RealmsUploadWorldPacker(directoryToPack, isCanceled).tarGzipArchive();
} }
private RealmsUploadWorldPacker(Path path, BooleanSupplier booleanSupplier) { private RealmsUploadWorldPacker(Path directoryToPack, BooleanSupplier isCanceled) {
this.isCanceled = booleanSupplier; this.isCanceled = isCanceled;
this.directoryToPack = path; this.directoryToPack = directoryToPack;
} }
private File tarGzipArchive() throws IOException { private File tarGzipArchive() throws IOException {
@ -54,20 +54,20 @@ public class RealmsUploadWorldPacker {
return var3; return var3;
} }
private void addFileToTarGz(TarArchiveOutputStream tarArchiveOutputStream, Path path, String string, boolean bl) throws IOException { private void addFileToTarGz(TarArchiveOutputStream stream, Path directory, String prefix, boolean isRootDirectory) throws IOException {
if (this.isCanceled.getAsBoolean()) { if (this.isCanceled.getAsBoolean()) {
throw new RealmsUploadCanceledException(); throw new RealmsUploadCanceledException();
} else { } else {
this.verifyBelowSizeLimit(tarArchiveOutputStream.getBytesWritten()); this.verifyBelowSizeLimit(stream.getBytesWritten());
File file = path.toFile(); File file = directory.toFile();
String string2 = bl ? string : string + file.getName(); String string = isRootDirectory ? prefix : prefix + file.getName();
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file, string2); TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file, string);
tarArchiveOutputStream.putArchiveEntry(tarArchiveEntry); stream.putArchiveEntry(tarArchiveEntry);
if (file.isFile()) { if (file.isFile()) {
InputStream inputStream = new FileInputStream(file); InputStream inputStream = new FileInputStream(file);
try { try {
inputStream.transferTo(tarArchiveOutputStream); inputStream.transferTo(stream);
} catch (Throwable var14) { } catch (Throwable var14) {
try { try {
inputStream.close(); inputStream.close();
@ -79,21 +79,21 @@ public class RealmsUploadWorldPacker {
} }
inputStream.close(); inputStream.close();
tarArchiveOutputStream.closeArchiveEntry(); stream.closeArchiveEntry();
} else { } else {
tarArchiveOutputStream.closeArchiveEntry(); stream.closeArchiveEntry();
File[] files = file.listFiles(); File[] files = file.listFiles();
if (files != null) { if (files != null) {
for (File file2 : files) { for (File file2 : files) {
this.addFileToTarGz(tarArchiveOutputStream, file2.toPath(), string2 + "/", false); this.addFileToTarGz(stream, file2.toPath(), string + "/", false);
} }
} }
} }
} }
} }
private void verifyBelowSizeLimit(long l) { private void verifyBelowSizeLimit(long size) {
if (l > 5368709120L) { if (size > 5368709120L) {
throw new RealmsUploadTooLargeException(5368709120L); throw new RealmsUploadTooLargeException(5368709120L);
} }
} }

View file

@ -37,15 +37,13 @@ public class RealmsWorldUpload {
@Nullable @Nullable
private FileUpload uploadTask; private FileUpload uploadTask;
public RealmsWorldUpload( public RealmsWorldUpload(Path worldFolder, RealmsWorldOptions worldOptions, User user, long realmId, int slotId, RealmsWorldUploadStatusTracker statusCallback) {
Path path, RealmsWorldOptions realmsWorldOptions, User user, long l, int i, RealmsWorldUploadStatusTracker realmsWorldUploadStatusTracker this.worldFolder = worldFolder;
) { this.worldOptions = worldOptions;
this.worldFolder = path;
this.worldOptions = realmsWorldOptions;
this.user = user; this.user = user;
this.realmId = l; this.realmId = realmId;
this.slotId = i; this.slotId = slotId;
this.statusCallback = realmsWorldUploadStatusTracker; this.statusCallback = statusCallback;
} }
public CompletableFuture<?> packAndUpload() { public CompletableFuture<?> packAndUpload() {

View file

@ -20,6 +20,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.ServerData.Type;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -185,11 +186,11 @@ public class RealmsServer extends ValueObject {
return map; return map;
} }
private static RealmsSettings parseSettings(JsonElement jsonElement) { private static RealmsSettings parseSettings(JsonElement json) {
boolean bl = false; boolean bl = false;
if (jsonElement.isJsonArray()) { if (json.isJsonArray()) {
for (JsonElement jsonElement2 : jsonElement.getAsJsonArray()) { for (JsonElement jsonElement : json.getAsJsonArray()) {
JsonObject jsonObject = jsonElement2.getAsJsonObject(); JsonObject jsonObject = jsonElement.getAsJsonObject();
bl = readBoolean(jsonObject, "hardcore", bl); bl = readBoolean(jsonObject, "hardcore", bl);
} }
} }
@ -197,9 +198,9 @@ public class RealmsServer extends ValueObject {
return new RealmsSettings(bl); return new RealmsSettings(bl);
} }
private static boolean readBoolean(JsonObject jsonObject, String string, boolean bl) { private static boolean readBoolean(JsonObject json, String memberName, boolean defaultValue) {
String string2 = JsonUtils.getStringOr("name", jsonObject, null); String string = JsonUtils.getStringOr("name", json, null);
return string2 != null && string2.equals(string) ? JsonUtils.getBooleanOr("value", jsonObject, bl) : bl; return string != null && string.equals(memberName) ? JsonUtils.getBooleanOr("value", json, defaultValue) : defaultValue;
} }
private static Map<Integer, RealmsWorldOptions> createEmptySlots() { private static Map<Integer, RealmsWorldOptions> createEmptySlots() {
@ -333,7 +334,7 @@ public class RealmsServer extends ValueObject {
} }
public ServerData toServerData(String ip) { public ServerData toServerData(String ip) {
return new ServerData((String)Objects.requireNonNullElse(this.name, "unknown server"), ip, ServerData.Type.REALM); return new ServerData((String)Objects.requireNonNullElse(this.name, "unknown server"), ip, Type.REALM);
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)

View file

@ -44,18 +44,28 @@ public class RealmsWorldOptions extends ValueObject {
private static final String DEFAULT_TEMPLATE_IMAGE = null; private static final String DEFAULT_TEMPLATE_IMAGE = null;
public RealmsWorldOptions( public RealmsWorldOptions(
boolean bl, boolean bl2, int i, boolean bl3, int j, int k, boolean bl4, boolean bl5, String string, String string2, RealmsServer.Compatibility compatibility boolean pvp,
boolean spawnMonsters,
int spawnProtection,
boolean commandBlocks,
int difficulty,
int gameMode,
boolean hardcore,
boolean forceGameMode,
String slotName,
String version,
RealmsServer.Compatibility compatibility
) { ) {
this.pvp = bl; this.pvp = pvp;
this.spawnMonsters = bl2; this.spawnMonsters = spawnMonsters;
this.spawnProtection = i; this.spawnProtection = spawnProtection;
this.commandBlocks = bl3; this.commandBlocks = commandBlocks;
this.difficulty = j; this.difficulty = difficulty;
this.gameMode = k; this.gameMode = gameMode;
this.hardcore = bl4; this.hardcore = hardcore;
this.forceGameMode = bl5; this.forceGameMode = forceGameMode;
this.slotName = string; this.slotName = slotName;
this.version = string2; this.version = version;
this.compatibility = compatibility; this.compatibility = compatibility;
} }
@ -63,12 +73,12 @@ public class RealmsWorldOptions extends ValueObject {
return new RealmsWorldOptions(true, true, 0, false, 2, 0, false, false, "", "", DEFAULT_COMPATIBILITY); return new RealmsWorldOptions(true, true, 0, false, 2, 0, false, false, "", "", DEFAULT_COMPATIBILITY);
} }
public static RealmsWorldOptions createDefaultsWith(GameType gameType, Difficulty difficulty, boolean bl, String string, String string2) { public static RealmsWorldOptions createDefaultsWith(GameType gameMode, Difficulty difficulty, boolean hardcore, String version, String slotName) {
return new RealmsWorldOptions(true, true, 0, false, difficulty.getId(), gameType.getId(), bl, false, string2, string, DEFAULT_COMPATIBILITY); return new RealmsWorldOptions(true, true, 0, false, difficulty.getId(), gameMode.getId(), hardcore, false, slotName, version, DEFAULT_COMPATIBILITY);
} }
public static RealmsWorldOptions createFromSettings(LevelSettings levelSettings, String string) { public static RealmsWorldOptions createFromSettings(LevelSettings settings, String version) {
return createDefaultsWith(levelSettings.gameType(), levelSettings.difficulty(), levelSettings.hardcore(), string, levelSettings.levelName()); return createDefaultsWith(settings.gameType(), settings.difficulty(), settings.hardcore(), version, settings.levelName());
} }
public static RealmsWorldOptions createEmptyDefaults() { public static RealmsWorldOptions createEmptyDefaults() {
@ -81,22 +91,22 @@ public class RealmsWorldOptions extends ValueObject {
this.empty = empty; this.empty = empty;
} }
public static RealmsWorldOptions parse(JsonObject jsonObject, RealmsSettings realmsSettings) { public static RealmsWorldOptions parse(JsonObject json, RealmsSettings realmsSettings) {
RealmsWorldOptions realmsWorldOptions = new RealmsWorldOptions( RealmsWorldOptions realmsWorldOptions = new RealmsWorldOptions(
JsonUtils.getBooleanOr("pvp", jsonObject, true), JsonUtils.getBooleanOr("pvp", json, true),
JsonUtils.getBooleanOr("spawnMonsters", jsonObject, true), JsonUtils.getBooleanOr("spawnMonsters", json, true),
JsonUtils.getIntOr("spawnProtection", jsonObject, 0), JsonUtils.getIntOr("spawnProtection", json, 0),
JsonUtils.getBooleanOr("commandBlocks", jsonObject, false), JsonUtils.getBooleanOr("commandBlocks", json, false),
JsonUtils.getIntOr("difficulty", jsonObject, 2), JsonUtils.getIntOr("difficulty", json, 2),
JsonUtils.getIntOr("gameMode", jsonObject, 0), JsonUtils.getIntOr("gameMode", json, 0),
realmsSettings.hardcore(), realmsSettings.hardcore(),
JsonUtils.getBooleanOr("forceGameMode", jsonObject, false), JsonUtils.getBooleanOr("forceGameMode", json, false),
JsonUtils.getRequiredStringOr("slotName", jsonObject, ""), JsonUtils.getRequiredStringOr("slotName", json, ""),
JsonUtils.getRequiredStringOr("version", jsonObject, ""), JsonUtils.getRequiredStringOr("version", json, ""),
RealmsServer.getCompatibility(JsonUtils.getRequiredStringOr("compatibility", jsonObject, RealmsServer.Compatibility.UNVERIFIABLE.name())) RealmsServer.getCompatibility(JsonUtils.getRequiredStringOr("compatibility", json, RealmsServer.Compatibility.UNVERIFIABLE.name()))
); );
realmsWorldOptions.templateId = JsonUtils.getLongOr("worldTemplateId", jsonObject, -1L); realmsWorldOptions.templateId = JsonUtils.getLongOr("worldTemplateId", json, -1L);
realmsWorldOptions.templateImage = JsonUtils.getStringOr("worldTemplateImage", jsonObject, DEFAULT_TEMPLATE_IMAGE); realmsWorldOptions.templateImage = JsonUtils.getStringOr("worldTemplateImage", json, DEFAULT_TEMPLATE_IMAGE);
return realmsWorldOptions; return realmsWorldOptions;
} }

View file

@ -40,28 +40,30 @@ public abstract class RowButton {
public abstract void onClick(int index); public abstract void onClick(int index);
public static void drawButtonsInRow(GuiGraphics guiGraphics, List<RowButton> list, AbstractSelectionList<?> abstractSelectionList, int i, int j, int k, int l) { public static void drawButtonsInRow(
for (RowButton rowButton : list) { GuiGraphics guiGraphics, List<RowButton> rowButtons, AbstractSelectionList<?> pendingInvitations, int x, int y, int mouseX, int mouseY
if (abstractSelectionList.getRowWidth() > rowButton.getRight()) { ) {
rowButton.drawForRowAt(guiGraphics, i, j, k, l); for (RowButton rowButton : rowButtons) {
if (pendingInvitations.getRowWidth() > rowButton.getRight()) {
rowButton.drawForRowAt(guiGraphics, x, y, mouseX, mouseY);
} }
} }
} }
public static void rowButtonMouseClicked( public static void rowButtonMouseClicked(
AbstractSelectionList<?> abstractSelectionList, ObjectSelectionList.Entry<?> entry, List<RowButton> list, int i, double d, double e AbstractSelectionList<?> pendingInvitations, ObjectSelectionList.Entry<?> entry, List<RowButton> rowButtons, int button, double mouseX, double mouseY
) { ) {
int j = abstractSelectionList.children().indexOf(entry); int i = pendingInvitations.children().indexOf(entry);
if (j > -1) { if (i > -1) {
abstractSelectionList.setSelectedIndex(j); pendingInvitations.setSelectedIndex(i);
int k = abstractSelectionList.getRowLeft(); int j = pendingInvitations.getRowLeft();
int l = abstractSelectionList.getRowTop(j); int k = pendingInvitations.getRowTop(i);
int m = (int)(d - k); int l = (int)(mouseX - j);
int n = (int)(e - l); int m = (int)(mouseY - k);
for (RowButton rowButton : list) { for (RowButton rowButton : rowButtons) {
if (m >= rowButton.xOffset && m <= rowButton.getRight() && n >= rowButton.yOffset && n <= rowButton.getBottom()) { if (l >= rowButton.xOffset && l <= rowButton.getRight() && m >= rowButton.yOffset && m <= rowButton.getBottom()) {
rowButton.onClick(j); rowButton.onClick(i);
} }
} }
} }

View file

@ -35,10 +35,10 @@ public class RealmsCreateRealmScreen extends RealmsScreen {
private EditBox descriptionBox; private EditBox descriptionBox;
private final Runnable createWorldRunnable; private final Runnable createWorldRunnable;
public RealmsCreateRealmScreen(RealmsMainScreen realmsMainScreen, RealmsServer realmsServer, boolean bl) { public RealmsCreateRealmScreen(RealmsMainScreen lastScreen, RealmsServer server, boolean isSnapshor) {
super(CREATE_REALM_TEXT); super(CREATE_REALM_TEXT);
this.lastScreen = realmsMainScreen; this.lastScreen = lastScreen;
this.createWorldRunnable = () -> this.createWorld(realmsServer, bl); this.createWorldRunnable = () -> this.createWorld(server, isSnapshor);
} }
@Override @Override
@ -71,17 +71,17 @@ public class RealmsCreateRealmScreen extends RealmsScreen {
this.layout.arrangeElements(); this.layout.arrangeElements();
} }
private void createWorld(RealmsServer realmsServer, boolean bl) { private void createWorld(RealmsServer server, boolean isSnapshot) {
if (!realmsServer.isSnapshotRealm() && bl) { if (!server.isSnapshotRealm() && isSnapshot) {
AtomicBoolean atomicBoolean = new AtomicBoolean(); AtomicBoolean atomicBoolean = new AtomicBoolean();
this.minecraft.setScreen(new AlertScreen(() -> { this.minecraft.setScreen(new AlertScreen(() -> {
atomicBoolean.set(true); atomicBoolean.set(true);
this.lastScreen.resetScreen(); this.lastScreen.resetScreen();
this.minecraft.setScreen(this.lastScreen); this.minecraft.setScreen(this.lastScreen);
}, Component.translatable("mco.upload.preparing"), Component.empty())); }, Component.translatable("mco.upload.preparing"), Component.empty()));
CompletableFuture.supplyAsync(() -> createSnapshotRealm(realmsServer), Util.backgroundExecutor()).thenAcceptAsync(realmsServerx -> { CompletableFuture.supplyAsync(() -> createSnapshotRealm(server), Util.backgroundExecutor()).thenAcceptAsync(realmsServer -> {
if (!atomicBoolean.get()) { if (!atomicBoolean.get()) {
this.showResetWorldScreen(realmsServerx); this.showResetWorldScreen(realmsServer);
} }
}, this.minecraft).exceptionallyAsync(throwable -> { }, this.minecraft).exceptionallyAsync(throwable -> {
this.lastScreen.resetScreen(); this.lastScreen.resetScreen();
@ -96,28 +96,26 @@ public class RealmsCreateRealmScreen extends RealmsScreen {
return null; return null;
}, this.minecraft); }, this.minecraft);
} else { } else {
this.showResetWorldScreen(realmsServer); this.showResetWorldScreen(server);
} }
} }
private static RealmsServer createSnapshotRealm(RealmsServer realmsServer) { private static RealmsServer createSnapshotRealm(RealmsServer server) {
RealmsClient realmsClient = RealmsClient.create(); RealmsClient realmsClient = RealmsClient.create();
try { try {
return realmsClient.createSnapshotRealm(realmsServer.id); return realmsClient.createSnapshotRealm(server.id);
} catch (RealmsServiceException var3) { } catch (RealmsServiceException var3) {
throw new RuntimeException(var3); throw new RuntimeException(var3);
} }
} }
private void showResetWorldScreen(RealmsServer realmsServer) { private void showResetWorldScreen(RealmsServer server) {
RealmCreationTask realmCreationTask = new RealmCreationTask(realmsServer.id, this.nameBox.getValue(), this.descriptionBox.getValue()); RealmCreationTask realmCreationTask = new RealmCreationTask(server.id, this.nameBox.getValue(), this.descriptionBox.getValue());
RealmsResetWorldScreen realmsResetWorldScreen = RealmsResetWorldScreen.forNewRealm( RealmsResetWorldScreen realmsResetWorldScreen = RealmsResetWorldScreen.forNewRealm(this, server, realmCreationTask, () -> this.minecraft.execute(() -> {
this, realmsServer, realmCreationTask, () -> this.minecraft.execute(() -> {
RealmsMainScreen.refreshServerList(); RealmsMainScreen.refreshServerList();
this.minecraft.setScreen(this.lastScreen); this.minecraft.setScreen(this.lastScreen);
}) }));
);
this.minecraft.setScreen(realmsResetWorldScreen); this.minecraft.setScreen(realmsResetWorldScreen);
} }

View file

@ -85,13 +85,13 @@ public class RealmsPendingInvitesScreen extends RealmsScreen {
this.minecraft.setScreen(this.lastScreen); this.minecraft.setScreen(this.lastScreen);
} }
void handleInvitation(boolean bl) { void handleInvitation(boolean accept) {
if (this.pendingInvitationSelectionList.getSelected() instanceof RealmsPendingInvitesScreen.Entry entry) { if (this.pendingInvitationSelectionList.getSelected() instanceof RealmsPendingInvitesScreen.Entry entry) {
String string = entry.pendingInvite.invitationId; String string = entry.pendingInvite.invitationId;
CompletableFuture.supplyAsync(() -> { CompletableFuture.supplyAsync(() -> {
try { try {
RealmsClient realmsClient = RealmsClient.create(); RealmsClient realmsClient = RealmsClient.create();
if (bl) { if (accept) {
realmsClient.acceptInvitation(string); realmsClient.acceptInvitation(string);
} else { } else {
realmsClient.rejectInvitation(string); realmsClient.rejectInvitation(string);
@ -107,7 +107,7 @@ public class RealmsPendingInvitesScreen extends RealmsScreen {
this.pendingInvitationSelectionList.removeInvitation(entry); this.pendingInvitationSelectionList.removeInvitation(entry);
this.updateButtonStates(); this.updateButtonStates();
RealmsDataFetcher realmsDataFetcher = this.minecraft.realmsDataFetcher(); RealmsDataFetcher realmsDataFetcher = this.minecraft.realmsDataFetcher();
if (bl) { if (accept) {
realmsDataFetcher.serverListUpdateTask.reset(); realmsDataFetcher.serverListUpdateTask.reset();
} }
@ -192,8 +192,8 @@ public class RealmsPendingInvitesScreen extends RealmsScreen {
} }
@Override @Override
public void setSelectedIndex(int i) { public void setSelectedIndex(int selected) {
super.setSelectedIndex(i); super.setSelectedIndex(selected);
RealmsPendingInvitesScreen.this.updateButtonStates(); RealmsPendingInvitesScreen.this.updateButtonStates();
} }

View file

@ -140,9 +140,9 @@ public class GetServerDetailsTask extends LongRunningTask {
private CompletableFuture<?> scheduleResourcePackDownload(RealmsServerAddress serverAddress, UUID id) { private CompletableFuture<?> scheduleResourcePackDownload(RealmsServerAddress serverAddress, UUID id) {
try { try {
if (serverAddress.resourcePackUrl != null) { if (serverAddress.resourcePackUrl == null) {
return CompletableFuture.failedFuture(new IllegalStateException("resourcePackUrl was null")); return CompletableFuture.failedFuture(new IllegalStateException("resourcePackUrl was null"));
} else if (serverAddress.resourcePackHash != null) { } else if (serverAddress.resourcePackHash == null) {
return CompletableFuture.failedFuture(new IllegalStateException("resourcePackHash was null")); return CompletableFuture.failedFuture(new IllegalStateException("resourcePackHash was null"));
} else { } else {
DownloadedPackSource downloadedPackSource = Minecraft.getInstance().getDownloadedPackSource(); DownloadedPackSource downloadedPackSource = Minecraft.getInstance().getDownloadedPackSource();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/minecraft/structure/end_city/ship.nbt (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more