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;
}
public void applyLayeringTransform(Matrix4f matrix4f, float f) {
this.layeringTransform.apply(matrix4f, f);
public void applyLayeringTransform(Matrix4f modelViewMatrix, float distance) {
this.layeringTransform.apply(modelViewMatrix, distance);
}
@FunctionalInterface

View file

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

View file

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

View file

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

View file

@ -18,19 +18,19 @@ public class GpuBuffer implements AutoCloseable {
public final int handle;
public int size;
public GpuBuffer(BufferType bufferType, BufferUsage bufferUsage, int i) {
this.type = bufferType;
this.size = i;
this.usage = bufferUsage;
public GpuBuffer(BufferType type, BufferUsage usage, int size) {
this.type = type;
this.size = size;
this.usage = usage;
this.handle = GlStateManager._glGenBuffers();
}
public GpuBuffer(BufferType bufferType, BufferUsage bufferUsage, ByteBuffer byteBuffer) {
this(bufferType, bufferUsage, byteBuffer.remaining());
this.write(byteBuffer, 0);
public GpuBuffer(BufferType type, BufferUsage usage, ByteBuffer buffer) {
this(type, usage, buffer.remaining());
this.write(buffer, 0);
}
public void resize(int i) {
public void resize(int size) {
if (this.closed) {
throw new IllegalStateException("Buffer already closed");
} else {
@ -38,40 +38,40 @@ public class GpuBuffer implements AutoCloseable {
MEMORY_POOl.free(this.handle);
}
this.size = i;
this.size = size;
if (this.usage.writable) {
this.initialized = false;
} else {
this.bind();
GlStateManager._glBufferData(this.type.id, i, this.usage.id);
MEMORY_POOl.malloc(this.handle, i);
GlStateManager._glBufferData(this.type.id, size, this.usage.id);
MEMORY_POOl.malloc(this.handle, size);
this.initialized = true;
}
}
}
public void write(ByteBuffer byteBuffer, int i) {
public void write(ByteBuffer buffer, int offset) {
if (this.closed) {
throw new IllegalStateException("Buffer already closed");
} else if (!this.usage.writable) {
throw new IllegalStateException("Buffer is not writable");
} else {
int j = byteBuffer.remaining();
if (j + i > this.size) {
int i = buffer.remaining();
if (i + offset > this.size) {
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 {
this.bind();
if (this.initialized) {
GlStateManager._glBufferSubData(this.type.id, i, byteBuffer);
} else if (i == 0 && j == this.size) {
GlStateManager._glBufferData(this.type.id, byteBuffer, this.usage.id);
GlStateManager._glBufferSubData(this.type.id, offset, buffer);
} else if (offset == 0 && i == this.size) {
GlStateManager._glBufferData(this.type.id, buffer, this.usage.id);
MEMORY_POOl.malloc(this.handle, this.size);
this.initialized = true;
} else {
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);
this.initialized = true;
}
@ -85,18 +85,18 @@ public class GpuBuffer implements AutoCloseable {
}
@Nullable
public GpuBuffer.ReadView read(int i, int j) {
public GpuBuffer.ReadView read(int offset, int length) {
if (this.closed) {
throw new IllegalStateException("Buffer already closed");
} else if (!this.usage.readable) {
throw new IllegalStateException("Buffer is not readable");
} else if (i + j > this.size) {
} else if (offset + length > this.size) {
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 {
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);
}
}
@ -120,9 +120,9 @@ public class GpuBuffer implements AutoCloseable {
private final int target;
private final ByteBuffer data;
protected ReadView(int i, ByteBuffer byteBuffer) {
this.target = i;
this.data = byteBuffer;
protected ReadView(int target, ByteBuffer data) {
this.target = target;
this.data = 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) {
return true;
} else {
int i = GlStateManager._glClientWaitSync(this.handle, 0, l);
int i = GlStateManager._glClientWaitSync(this.handle, 0, timeout);
if (i == 37147) {
return false;
} else if (i == 37149) {

View file

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

View file

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

View file

@ -7,15 +7,15 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
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 executes(Runnable runnable);
void executes(Runnable task);
}

View file

@ -38,14 +38,14 @@ public abstract class RenderTarget {
this.depthBufferId = -1;
}
public void resize(int i, int j) {
public void resize(int width, int height) {
RenderSystem.assertOnRenderThreadOrInit();
GlStateManager._enableDepthTest();
if (this.frameBufferId >= 0) {
this.destroyBuffers();
}
this.createBuffers(i, j);
this.createBuffers(width, height);
GlStateManager._glBindFramebuffer(36160, 0);
}
@ -78,14 +78,14 @@ public abstract class RenderTarget {
GlStateManager._glBindFramebuffer(36160, 0);
}
public void createBuffers(int i, int j) {
public void createBuffers(int width, int height) {
RenderSystem.assertOnRenderThreadOrInit();
int k = RenderSystem.maxSupportedTextureSize();
if (i > 0 && i <= k && j > 0 && j <= k) {
this.viewWidth = i;
this.viewHeight = j;
this.width = i;
this.height = j;
int i = RenderSystem.maxSupportedTextureSize();
if (width > 0 && width <= i && height > 0 && height <= i) {
this.viewWidth = width;
this.viewHeight = height;
this.width = width;
this.height = height;
this.frameBufferId = GlStateManager.glGenFramebuffers();
this.colorTextureId = TextureUtil.generateTextureId();
if (this.useDepth) {
@ -114,7 +114,7 @@ public abstract class RenderTarget {
this.clear();
this.unbindRead();
} 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);
}
public void blitAndBlendToScreen(int i, int j) {
public void blitAndBlendToScreen(int width, int height) {
RenderSystem.assertOnRenderThread();
GlStateManager._colorMask(true, true, true, false);
GlStateManager._disableDepthTest();
GlStateManager._depthMask(false);
GlStateManager._viewport(0, 0, i, j);
GlStateManager._viewport(0, 0, width, height);
CompiledShaderProgram compiledShaderProgram = (CompiledShaderProgram)Objects.requireNonNull(
RenderSystem.setShader(CoreShaders.BLIT_SCREEN), "Blit shader not loaded"
);

View file

@ -6,9 +6,9 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class TextureTarget extends RenderTarget {
public TextureTarget(int i, int j, boolean bl) {
super(bl);
public TextureTarget(int width, int height, boolean useDepth) {
super(useDepth);
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 {
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(() -> {
try {
Thread.sleep(CRASH_REPORT_PRELOAD_LOAD);
@ -20,7 +20,7 @@ public class ClientShutdownWatchdog {
return;
}
CrashReport crashReport = ServerWatchdog.createWatchdogCrashReport("Client shutdown", l);
CrashReport crashReport = ServerWatchdog.createWatchdogCrashReport("Client shutdown", threadId);
Minecraft.saveReport(file, crashReport);
});
thread.setDaemon(true);

View file

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

View file

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

View file

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

View file

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

View file

@ -126,13 +126,13 @@ public abstract class GlslPreprocessor {
@Nullable
public abstract String applyImport(boolean useFullPath, String directory);
public static String injectDefines(String string, ShaderDefines shaderDefines) {
if (shaderDefines.isEmpty()) {
return string;
public static String injectDefines(String shaderSource, ShaderDefines defines) {
if (defines.isEmpty()) {
return shaderSource;
} else {
int i = string.indexOf(10);
int i = shaderSource.indexOf(10);
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 Deque<CrossFrameResourcePool.ResourceEntry<?>> pool = new ArrayDeque();
public CrossFrameResourcePool(int i) {
this.framesToKeepResource = i;
public CrossFrameResourcePool(int framesToKeepResource) {
this.framesToKeepResource = framesToKeepResource;
}
public void endFrame() {
@ -30,23 +30,23 @@ public class CrossFrameResourcePool implements GraphicsResourceAllocator, AutoCl
}
@Override
public <T> T acquire(ResourceDescriptor<T> resourceDescriptor) {
public <T> T acquire(ResourceDescriptor<T> descriptor) {
Iterator<? extends CrossFrameResourcePool.ResourceEntry<?>> iterator = this.pool.iterator();
while (iterator.hasNext()) {
CrossFrameResourcePool.ResourceEntry<?> resourceEntry = (CrossFrameResourcePool.ResourceEntry<?>)iterator.next();
if (resourceEntry.descriptor.equals(resourceDescriptor)) {
if (resourceEntry.descriptor.equals(descriptor)) {
iterator.remove();
return (T)resourceEntry.value;
}
}
return resourceDescriptor.allocate();
return descriptor.allocate();
}
@Override
public <T> void release(ResourceDescriptor<T> resourceDescriptor, T object) {
this.pool.addFirst(new CrossFrameResourcePool.ResourceEntry<>(resourceDescriptor, object, this.framesToKeepResource));
public <T> void release(ResourceDescriptor<T> descriptor, T value) {
this.pool.addFirst(new CrossFrameResourcePool.ResourceEntry<>(descriptor, value, this.framesToKeepResource));
}
public void clear() {
@ -70,10 +70,10 @@ public class CrossFrameResourcePool implements GraphicsResourceAllocator, AutoCl
final T value;
int framesToLive;
ResourceEntry(ResourceDescriptor<T> resourceDescriptor, T object, int i) {
this.descriptor = resourceDescriptor;
this.value = object;
this.framesToLive = i;
ResourceEntry(ResourceDescriptor<T> descriptor, T value, int framesToLive) {
this.descriptor = descriptor;
this.value = value;
this.framesToLive = framesToLive;
}
public void close() {

View file

@ -7,17 +7,17 @@ import net.fabricmc.api.Environment;
public interface GraphicsResourceAllocator {
GraphicsResourceAllocator UNPOOLED = new GraphicsResourceAllocator() {
@Override
public <T> T acquire(ResourceDescriptor<T> resourceDescriptor) {
return resourceDescriptor.allocate();
public <T> T acquire(ResourceDescriptor<T> descriptor) {
return descriptor.allocate();
}
@Override
public <T> void release(ResourceDescriptor<T> resourceDescriptor, T object) {
resourceDescriptor.free(object);
public <T> void release(ResourceDescriptor<T> descriptor, T value) {
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> {
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 int shaderId;
private CompiledShader(int i, ResourceLocation resourceLocation) {
this.id = resourceLocation;
this.shaderId = i;
private CompiledShader(int shaderId, ResourceLocation id) {
this.id = id;
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();
int i = GlStateManager.glCreateShader(type.glType());
GlStateManager.glShaderSource(i, string);
GlStateManager.glShaderSource(i, source);
GlStateManager.glCompileShader(i);
if (GlStateManager.glGetShaderi(i, 35713) == 0) {
String string2 = StringUtils.trim(GlStateManager.glGetShaderInfoLog(i, 32768));
throw new ShaderManager.CompilationException("Couldn't compile " + type.getName() + " shader (" + resourceLocation + ") : " + string2);
String string = StringUtils.trim(GlStateManager.glGetShaderInfoLog(i, 32768));
throw new ShaderManager.CompilationException("Couldn't compile " + type.getName() + " shader (" + shaderId + ") : " + string);
} 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 int glType;
private Type(final String string2, final String string3, final int j) {
this.name = string2;
this.extension = string3;
this.glType = j;
private Type(final String name, final String extension, final int glType) {
this.name = name;
this.extension = extension;
this.glType = glType;
}
@Nullable
public static CompiledShader.Type byLocation(ResourceLocation resourceLocation) {
public static CompiledShader.Type byLocation(ResourceLocation location) {
for (CompiledShader.Type type : TYPES) {
if (resourceLocation.getPath().endsWith(type.extension)) {
if (location.getPath().endsWith(type.extension)) {
return type;
}
}

View file

@ -9,7 +9,6 @@ import java.util.Arrays;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.ShaderProgramConfig;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Vector3f;
@ -39,16 +38,16 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
private final FloatBuffer floatValues;
private final String name;
public Uniform(String string, int i, int j) {
this.name = string;
this.count = j;
this.type = i;
if (i <= 3) {
this.intValues = MemoryUtil.memAllocInt(j);
public Uniform(String name, int type, int count) {
this.name = name;
this.count = count;
this.type = type;
if (type <= 3) {
this.intValues = MemoryUtil.memAllocInt(count);
this.floatValues = null;
} else {
this.intValues = null;
this.floatValues = MemoryUtil.memAllocFloat(j);
this.floatValues = MemoryUtil.memAllocFloat(count);
}
this.location = -1;
@ -63,17 +62,17 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
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());
}
public void setFromConfig(List<Float> list, int i) {
float[] fs = new float[Math.max(i, 16)];
if (list.size() == 1) {
Arrays.fill(fs, (Float)list.getFirst());
public void setFromConfig(List<Float> values, int count) {
float[] fs = new float[Math.max(count, 16)];
if (values.size() == 1) {
Arrays.fill(fs, (Float)values.getFirst());
} else {
for (int j = 0; j < list.size(); j++) {
fs[j] = (Float)list.get(j);
for (int i = 0; i < values.size(); i++) {
fs[i] = (Float)values.get(i);
}
}
@ -82,7 +81,7 @@ public class Uniform extends AbstractUniform implements AutoCloseable {
} else if (this.type <= 7) {
this.setSafe(fs[0], fs[1], fs[2], fs[3]);
} 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;
import com.mojang.blaze3d.vertex.ByteBufferBuilder.Result;
import com.mojang.blaze3d.vertex.MeshData.DrawState;
import java.nio.ByteOrder;
import java.util.stream.Collectors;
@ -75,7 +76,7 @@ public class BufferBuilder implements VertexConsumer {
if (this.vertices == 0) {
return null;
} else {
ByteBufferBuilder.Result result = this.buffer.build();
Result result = this.buffer.build();
if (result == null) {
return null;
} else {

View file

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

View file

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

View file

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

View file

@ -35,9 +35,9 @@ public class MatrixUtil {
);
}
private static GivensParameters approxGivensQuat(float f, float g, float h) {
float i = 2.0F * (f - h);
return G * g * g < i * i ? GivensParameters.fromUnnormalized(g, i) : PI_4;
private static GivensParameters approxGivensQuat(float topCorner, float oppositeDiagonalAverage, float bottomCorner) {
float f = 2.0F * (topCorner - bottomCorner);
return G * oppositeDiagonalAverage * oppositeDiagonalAverage < f * f ? GivensParameters.fromUnnormalized(oppositeDiagonalAverage, f) : PI_4;
}
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.logging.LogUtils;
import com.mojang.math.Axis;
import com.mojang.realmsclient.RealmsAvailability.Result;
import com.mojang.realmsclient.client.Ping;
import com.mojang.realmsclient.client.RealmsClient;
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.PlayerFaceRenderer;
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.WidgetSprites;
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.GridLayout;
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 boolean SNAPSHOT = !SharedConstants.getCurrentVersion().isStable();
private static boolean snapshotToggle = SNAPSHOT;
private final CompletableFuture<RealmsAvailability.Result> availability = RealmsAvailability.get();
private final CompletableFuture<Result> availability = RealmsAvailability.get();
@Nullable
private Subscription dataSubscription;
private final Set<UUID> handledSeenNotifications = new HashSet();
@ -627,7 +630,7 @@ public class RealmsMainScreen extends RealmsScreen {
case INCOMPATIBLE:
Minecraft.getInstance()
.setScreen(
new PopupScreen.Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
new Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
.setMessage(
Component.translatable(
"mco.compatibility.incompatible.series.popup.message",
@ -642,7 +645,7 @@ public class RealmsMainScreen extends RealmsScreen {
case RELEASE_TYPE_INCOMPATIBLE:
Minecraft.getInstance()
.setScreen(
new PopupScreen.Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
new Builder(lastScreen, INCOMPATIBLE_POPUP_TITLE)
.setMessage(INCOMPATIBLE_RELEASE_TYPE_POPUP_MESSAGE)
.addButton(CommonComponents.GUI_BACK, PopupScreen::onClose)
.build()
@ -652,7 +655,7 @@ public class RealmsMainScreen extends RealmsScreen {
}
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)));
refreshServerList();
}).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));
}
public static Component getGameModeComponent(int i, boolean bl) {
return (Component)(bl ? Component.translatable("gameMode.hardcore").withColor(-65536) : GameType.byId(i).getLongDisplayName());
public static Component getGameModeComponent(int gamemode, boolean hardcore) {
return (Component)(hardcore ? Component.translatable("gameMode.hardcore").withColor(-65536) : GameType.byId(gamemode).getLongDisplayName());
}
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
.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"))
.addButton(
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")
);
protected CrossButton(Button.OnPress onPress, Component message) {
protected CrossButton(OnPress onPress, Component message) {
super(0, 0, 14, 14, SPRITES, onPress);
this.setTooltip(Tooltip.create(message));
}
@ -902,26 +905,26 @@ public class RealmsMainScreen extends RealmsScreen {
return left + width - RealmsMainScreen.this.font.width(versionComponent) - 20;
}
protected int gameModeTextX(int i, int j, Component component) {
return i + j - RealmsMainScreen.this.font.width(component) - 20;
protected int gameModeTextX(int left, int width, Component component) {
return left + width - RealmsMainScreen.this.font.width(component) - 20;
}
protected int renderGameMode(RealmsServer realmsServer, GuiGraphics guiGraphics, int i, int j, int k) {
boolean bl = realmsServer.isHardcore;
int l = realmsServer.gameMode;
int m = i;
if (GameType.isValidId(l)) {
Component component = RealmsMainScreen.getGameModeComponent(l, bl);
m = this.gameModeTextX(i, j, component);
guiGraphics.drawString(RealmsMainScreen.this.font, component, m, this.secondLineY(k), -8355712, false);
protected int renderGameMode(RealmsServer server, GuiGraphics guiGraphics, int left, int width, int firstLineY) {
boolean bl = server.isHardcore;
int i = server.gameMode;
int j = left;
if (GameType.isValidId(i)) {
Component component = RealmsMainScreen.getGameModeComponent(i, bl);
j = this.gameModeTextX(left, width, component);
guiGraphics.drawString(RealmsMainScreen.this.font, component, j, this.secondLineY(firstLineY), -8355712, false);
}
if (bl) {
m -= 10;
guiGraphics.blitSprite(RenderType::guiTextured, RealmsMainScreen.HARDCORE_MODE_SPRITE, m, this.secondLineY(k), 8, 8);
j -= 10;
guiGraphics.blitSprite(RenderType::guiTextured, RealmsMainScreen.HARDCORE_MODE_SPRITE, j, this.secondLineY(firstLineY), 8, 8);
}
return m;
return j;
}
protected int firstLineY(int top) {
@ -953,7 +956,7 @@ public class RealmsMainScreen extends RealmsScreen {
}
@Environment(EnvType.CLIENT)
static class NotificationButton extends SpriteIconButton.CenteredIcon {
static class NotificationButton extends CenteredIcon {
private static final ResourceLocation[] NOTIFICATION_ICONS = new ResourceLocation[]{
ResourceLocation.withDefaultNamespace("notification/1"),
ResourceLocation.withDefaultNamespace("notification/2"),
@ -967,7 +970,7 @@ public class RealmsMainScreen extends RealmsScreen {
private static final int SPRITE_SIZE = 14;
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);
}
@ -1135,8 +1138,8 @@ public class RealmsMainScreen extends RealmsScreen {
super(Minecraft.getInstance(), RealmsMainScreen.this.width, RealmsMainScreen.this.height, 0, 36);
}
public void setSelected(@Nullable RealmsMainScreen.Entry entry) {
super.setSelected(entry);
public void setSelected(@Nullable RealmsMainScreen.Entry selected) {
super.setSelected(selected);
RealmsMainScreen.this.updateButtonStates();
}
@ -1145,55 +1148,55 @@ public class RealmsMainScreen extends RealmsScreen {
return 300;
}
void refreshEntries(RealmsMainScreen realmsMainScreen, @Nullable RealmsServer realmsServer) {
void refreshEntries(RealmsMainScreen screen, @Nullable RealmsServer server) {
this.clearEntries();
for (RealmsNotification realmsNotification : RealmsMainScreen.this.notifications) {
if (realmsNotification instanceof VisitUrl visitUrl) {
this.addEntriesForNotification(visitUrl, realmsMainScreen);
this.addEntriesForNotification(visitUrl, screen);
RealmsMainScreen.this.markNotificationsAsSeen(List.of(realmsNotification));
break;
}
}
this.refreshServerEntries(realmsServer);
this.refreshServerEntries(server);
}
private void refreshServerEntries(@Nullable RealmsServer realmsServer) {
for (RealmsServer realmsServer2 : RealmsMainScreen.this.availableSnapshotServers) {
this.addEntry(RealmsMainScreen.this.new AvailableSnapshotEntry(realmsServer2));
private void refreshServerEntries(@Nullable RealmsServer server) {
for (RealmsServer realmsServer : RealmsMainScreen.this.availableSnapshotServers) {
this.addEntry(RealmsMainScreen.this.new AvailableSnapshotEntry(realmsServer));
}
for (RealmsServer realmsServer2 : RealmsMainScreen.this.serverList) {
for (RealmsServer realmsServer : RealmsMainScreen.this.serverList) {
RealmsMainScreen.Entry entry;
if (RealmsMainScreen.isSnapshot() && !realmsServer2.isSnapshotRealm()) {
if (realmsServer2.state == RealmsServer.State.UNINITIALIZED) {
if (RealmsMainScreen.isSnapshot() && !realmsServer.isSnapshotRealm()) {
if (realmsServer.state == RealmsServer.State.UNINITIALIZED) {
continue;
}
entry = RealmsMainScreen.this.new ParentEntry(realmsServer2);
entry = RealmsMainScreen.this.new ParentEntry(realmsServer);
} else {
entry = RealmsMainScreen.this.new ServerEntry(realmsServer2);
entry = RealmsMainScreen.this.new ServerEntry(realmsServer);
}
this.addEntry(entry);
if (realmsServer != null && realmsServer.id == realmsServer2.id) {
if (server != null && server.id == realmsServer.id) {
this.setSelected(entry);
}
}
}
private void addEntriesForNotification(VisitUrl visitUrl, RealmsMainScreen realmsMainScreen) {
Component component = visitUrl.getMessage();
private void addEntriesForNotification(VisitUrl url, RealmsMainScreen mainScreen) {
Component component = url.getMessage();
int i = RealmsMainScreen.this.font.wordWrapHeight(component, 216);
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++) {
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) {
int l = this.textX(j);
int m = this.firstLineY(i);
int n = this.secondLineY(m);
private void renderSecondLine(GuiGraphics guiGraphics, int top, int left, int width) {
int i = this.textX(left);
int j = this.firstLineY(top);
int k = this.secondLineY(j);
String string = this.serverData.getMinigameName();
boolean bl = this.serverData.isMinigameActive();
if (bl && string != null) {
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 {
int o = this.renderGameMode(this.serverData, guiGraphics, j, k, m);
this.renderClampedString(guiGraphics, this.serverData.getDescription(), l, this.secondLineY(m), o, -8355712);
int l = this.renderGameMode(this.serverData, guiGraphics, left, width, j);
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.dto.UploadInfo;
import com.mojang.realmsclient.gui.screens.UploadResult;
import com.mojang.realmsclient.gui.screens.UploadResult.Builder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -69,12 +70,12 @@ public class FileUpload {
public UploadResult upload() {
if (this.uploadTask != null) {
return new UploadResult.Builder().build();
return new Builder().build();
} else {
this.uploadTask = CompletableFuture.supplyAsync(() -> this.requestUpload(0), Util.backgroundExecutor());
if (this.cancelled.get()) {
this.cancel();
return new UploadResult.Builder().build();
return new Builder().build();
} else {
return (UploadResult)this.uploadTask.join();
}
@ -89,7 +90,7 @@ public class FileUpload {
* @param retries The number of times this upload has already been attempted
*/
private UploadResult requestUpload(int retries) {
UploadResult.Builder builder = new UploadResult.Builder();
Builder builder = new Builder();
if (this.cancelled.get()) {
return builder.build();
} else {
@ -155,7 +156,7 @@ public class FileUpload {
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();
if (i == 401) {
LOGGER.debug("Realms server returned 401: {}", response.getFirstHeader("WWW-Authenticate"));
@ -199,10 +200,10 @@ public class FileUpload {
private final InputStream content;
private final UploadStatus uploadStatus;
public CustomInputStreamEntity(final InputStream inputStream, final long l, final UploadStatus uploadStatus) {
super(inputStream);
this.content = inputStream;
this.length = l;
public CustomInputStreamEntity(final InputStream content, final long length, final UploadStatus uploadStatus) {
super(content);
this.content = content;
this.length = length;
this.uploadStatus = uploadStatus;
}

View file

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

View file

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

View file

@ -33,18 +33,18 @@ public class RealmsCreateWorldFlow {
private static final Logger LOGGER = LogUtils.getLogger();
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(
minecraft,
screen,
lastScreen,
(createWorldScreen, layeredRegistryAccess, primaryLevelData, path) -> {
Path path2;
try {
path2 = createTemporaryWorldFolder(layeredRegistryAccess, primaryLevelData, path);
} catch (IOException var13) {
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;
}
@ -52,7 +52,7 @@ public class RealmsCreateWorldFlow {
primaryLevelData.getLevelSettings(), SharedConstants.getCurrentVersion().getName()
);
RealmsWorldUpload realmsWorldUpload = new RealmsWorldUpload(
path2, realmsWorldOptions, minecraft.getUser(), realmsServer.id, i, RealmsWorldUploadStatusTracker.noOp()
path2, realmsWorldOptions, minecraft.getUser(), server.id, slot, RealmsWorldUploadStatusTracker.noOp()
);
minecraft.forceSetScreen(
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) {
minecraft.forceSetScreen(screen2);
minecraft.forceSetScreen(resetWorldScreen);
} else {
if (throwable instanceof RealmsUploadFailedException realmsUploadFailedException) {
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());
}
minecraft.forceSetScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), screen2));
minecraft.forceSetScreen(new RealmsGenericErrorScreen(Component.translatable("mco.create.world.failed"), resetWorldScreen));
}
} else {
if (screen instanceof RealmsConfigureWorldScreen realmsConfigureWorldScreen) {
realmsConfigureWorldScreen.fetchServerData(realmsServer.id);
if (lastScreen instanceof RealmsConfigureWorldScreen realmsConfigureWorldScreen) {
realmsConfigureWorldScreen.fetchServerData(server.id);
}
if (realmCreationTask != null) {
RealmsMainScreen.play(realmsServer, screen, true);
RealmsMainScreen.play(server, lastScreen, true);
} else {
minecraft.forceSetScreen(screen);
minecraft.forceSetScreen(lastScreen);
}
RealmsMainScreen.refreshServerList();
@ -99,19 +99,17 @@ public class RealmsCreateWorldFlow {
);
}
private static Path createTemporaryWorldFolder(
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess, PrimaryLevelData primaryLevelData, @Nullable Path path
) throws IOException {
Path path2 = Files.createTempDirectory("minecraft_realms_world_upload");
if (path != null) {
Files.move(path, path2.resolve("datapacks"));
private static Path createTemporaryWorldFolder(LayeredRegistryAccess<RegistryLayer> registryAccess, PrimaryLevelData levelData, @Nullable Path tempDatapackDir) throws IOException {
Path path = Files.createTempDirectory("minecraft_realms_world_upload");
if (tempDatapackDir != null) {
Files.move(tempDatapackDir, path.resolve("datapacks"));
}
CompoundTag compoundTag = primaryLevelData.createTag(layeredRegistryAccess.compositeAccess(), null);
CompoundTag compoundTag = levelData.createTag(registryAccess.compositeAccess(), null);
CompoundTag compoundTag2 = new CompoundTag();
compoundTag2.put("Data", compoundTag);
Path path3 = Files.createFile(path2.resolve("level.dat"));
NbtIo.writeCompressed(compoundTag2, path3);
return path2;
Path path2 = Files.createFile(path.resolve("level.dat"));
NbtIo.writeCompressed(compoundTag2, path2);
return path;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -140,9 +140,9 @@ public class GetServerDetailsTask extends LongRunningTask {
private CompletableFuture<?> scheduleResourcePackDownload(RealmsServerAddress serverAddress, UUID id) {
try {
if (serverAddress.resourcePackUrl != null) {
if (serverAddress.resourcePackUrl == 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"));
} else {
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