Skip to content

Commit 882b397

Browse files
committed
Merge branch 'refs/heads/master' into fork/ghzdude/in-world-gui
2 parents 57a97f3 + 6bfbbc7 commit 882b397

25 files changed

Lines changed: 2102 additions & 43 deletions

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ modGroup = com.cleanroommc.modularui
88

99
# Version of your mod.
1010
# This field can be left empty if you want your mod's version to be determined by the latest git tag instead.
11-
modVersion = 2.4.3
11+
modVersion = 2.5.0-rc1
1212

1313
# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
1414
includeMCVersionJar = false

src/main/java/com/cleanroommc/modularui/screen/ContainerCustomizer.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.cleanroommc.modularui.screen;
22

33
import com.cleanroommc.modularui.widgets.slot.ModularSlot;
4-
54
import com.cleanroommc.modularui.widgets.slot.SlotGroup;
65

76
import net.minecraft.entity.player.EntityPlayer;
87
import net.minecraft.entity.player.InventoryPlayer;
98
import net.minecraft.inventory.ClickType;
9+
import net.minecraft.inventory.Container;
1010
import net.minecraft.inventory.IInventory;
1111
import net.minecraft.inventory.Slot;
1212
import net.minecraft.item.ItemStack;
13-
1413
import net.minecraft.world.World;
1514
import net.minecraftforge.items.ItemHandlerHelper;
1615

@@ -140,6 +139,40 @@ public void onContainerClosed() {}
140139
}
141140
clickedSlot.onSlotChanged();
142141
}
142+
container.detectAndSendChanges();
143+
return returnable;
144+
} else if (clickTypeIn == ClickType.PICKUP_ALL && slotId >= 0) {
145+
Slot slot = container.inventorySlots.get(slotId);
146+
ItemStack itemstack1 = inventoryplayer.getItemStack();
147+
148+
if (!itemstack1.isEmpty() && (slot == null || !slot.getHasStack() || !slot.canTakeStack(player))) {
149+
int i = mouseButton == 0 ? 0 : container.inventorySlots.size() - 1;
150+
int j = mouseButton == 0 ? 1 : -1;
151+
152+
for (int k = 0; k < 2; ++k) {
153+
for (int l = i; l >= 0 && l < container.inventorySlots.size() && itemstack1.getCount() < itemstack1.getMaxStackSize(); l += j) {
154+
Slot slot1 = container.inventorySlots.get(l);
155+
if (slot1 instanceof ModularSlot modularSlot && modularSlot.isPhantom()) continue;
156+
157+
if (slot1.getHasStack() && Container.canAddItemToSlot(slot1, itemstack1, true) && slot1.canTakeStack(player) && canMergeSlot(itemstack1, slot1)) {
158+
ItemStack itemstack2 = slot1.getStack();
159+
160+
if (k != 0 || itemstack2.getCount() != itemstack2.getMaxStackSize()) {
161+
int i1 = Math.min(itemstack1.getMaxStackSize() - itemstack1.getCount(), itemstack2.getCount());
162+
ItemStack itemstack3 = slot1.decrStackSize(i1);
163+
itemstack1.grow(i1);
164+
165+
if (itemstack3.isEmpty()) {
166+
slot1.putStack(ItemStack.EMPTY);
167+
}
168+
169+
slot1.onTake(player, itemstack3);
170+
}
171+
}
172+
}
173+
}
174+
}
175+
143176
container.detectAndSendChanges();
144177
return returnable;
145178
}
@@ -154,7 +187,7 @@ public void onContainerClosed() {}
154187
if (!stack.isEmpty()) {
155188
stack = stack.copy();
156189
int base = 0;
157-
if(stack.getCount() > stack.getMaxStackSize()) {
190+
if (stack.getCount() > stack.getMaxStackSize()) {
158191
base = stack.getCount() - stack.getMaxStackSize();
159192
stack.setCount(stack.getMaxStackSize());
160193
}

src/main/java/com/cleanroommc/modularui/screen/GuiScreenWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import org.jetbrains.annotations.NotNull;
4141
import org.lwjgl.input.Keyboard;
42+
import org.lwjgl.opengl.GL11;
4243

4344
import java.io.IOException;
4445
import java.util.Set;
Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.cleanroommc.modularui.test;
22

3-
import com.cleanroommc.modularui.api.drawable.IKey;
4-
import com.cleanroommc.modularui.api.layout.IViewportStack;
5-
import com.cleanroommc.modularui.drawable.GuiTextures;
63
import com.cleanroommc.modularui.screen.CustomModularScreen;
74
import com.cleanroommc.modularui.screen.ModularPanel;
85
import com.cleanroommc.modularui.screen.viewport.GuiContext;
9-
import com.cleanroommc.modularui.widget.Widget;
10-
11-
import net.minecraft.client.Minecraft;
6+
import com.cleanroommc.modularui.utils.fakeworld.ArraySchema;
7+
import com.cleanroommc.modularui.utils.fakeworld.ISchema;
8+
import com.cleanroommc.modularui.widgets.SchemaWidget;
129

1310
import org.jetbrains.annotations.NotNull;
1411

@@ -24,34 +21,50 @@ public class ResizerTest extends CustomModularScreen {
2421
.background(new SpriteDrawable(sprite))
2522
.size(20)
2623
.align(Alignment.Center));*/
27-
return ModularPanel.defaultPanel("main")
24+
/*TrackedDummyWorld world = new TrackedDummyWorld();
25+
world.addBlock(new BlockPos(0, 0, 0), new BlockInfo(Blocks.DIAMOND_BLOCK.getDefaultState()));
26+
world.addBlock(new BlockPos(0, 1, 0), new BlockInfo(Blocks.BEDROCK.getDefaultState()));
27+
world.addBlock(new BlockPos(1, 0, 1), new BlockInfo(Blocks.GOLD_BLOCK.getDefaultState()));*/
28+
/* return ModularPanel.defaultPanel("main")
2829
.size(150)
29-
.child(new SpinningWidget()
30-
.size(80, 20)
31-
.center()
32-
.background(GuiTextures.MC_BUTTON)
33-
.overlay(IKey.str("Text"))
34-
.addTooltipLine("Long Tooltip Line"));
35-
/*.child(new Column()
36-
.alignX(0.5f)
37-
.heightRel(1f)
38-
.margin(0, 7)
39-
.coverChildrenWidth()
40-
.mainAxisAlignment(Alignment.MainAxis.SPACE_BETWEEN)
41-
.child(new ButtonWidget<>().width(40))
42-
.child(new Row().height(30).widthRel(1f).background(GuiTextures.CHECKBOARD).debugName("row"))
43-
.child(new ButtonWidget<>()));*/
44-
}
30+
.overlay(new SchemaRenderer(BoxSchema.of(Minecraft.getMinecraft().world, new BlockPos(Minecraft.getMinecraft().player), 5))
31+
.cameraFunc((camera, schema) -> {
32+
double pitch = Math.PI / 4;
33+
double T = 4000D;
34+
double yaw = Minecraft.getSystemTime() % T / T * Math.PI * 2;
35+
camera.setLookAt(new BlockPos(Minecraft.getMinecraft().player), 20, yaw, pitch);
36+
})
37+
.isometric(true)
38+
.asIcon().size(140));*/
39+
40+
41+
/*MapSchema world = new MapSchema.Builder()
42+
.add(new BlockPos(0, 0, 0), Blocks.DIAMOND_BLOCK.getDefaultState())
43+
.add(new BlockPos(0, 1, 0), Blocks.BEDROCK.getDefaultState())
44+
.add(new BlockPos(0, 2, 0), Blocks.WOOL.getDefaultState())
45+
.add(new BlockPos(1, 0, 1), Blocks.GOLD_BLOCK.getDefaultState())
46+
.add(new BlockPos(0, 3, 0), Blocks.BEACON.getDefaultState())
47+
.build();*/
4548

46-
private static class SpinningWidget extends Widget<SpinningWidget> {
49+
ISchema schema = ArraySchema.builder()
50+
.layer("D D", " ", " ", " ")
51+
.layer(" DDD ", " E E ", " ", " ")
52+
.layer(" DDD ", " E ", " G ", " B ")
53+
.layer(" DDD ", " E E ", " ", " ")
54+
.layer("D D", " ", " ", " ")
55+
.where('D', "minecraft:gold_block")
56+
.where('E', "minecraft:emerald_block")
57+
.where('G', "minecraft:diamond_block")
58+
.where('B', "minecraft:beacon")
59+
.build();
4760

48-
@Override
49-
public void transform(IViewportStack stack) {
50-
super.transform(stack);
51-
stack.translate(getArea().width / 2f, getArea().height / 2f);
52-
float p = Minecraft.getSystemTime() % 4000 / 4000f;
53-
stack.rotateZ((float) (p * Math.PI * 2));
54-
stack.translate(-getArea().width / 2f, -getArea().height / 2f);
55-
}
61+
var panel = ModularPanel.defaultPanel("main").size(170);
62+
panel.child(new SchemaWidget(schema)
63+
.full())
64+
.child(new SchemaWidget.LayerButton(schema, 0, 3)
65+
.bottom(1)
66+
.left(1)
67+
.size(16));
68+
return panel;
5669
}
5770
}

src/main/java/com/cleanroommc/modularui/utils/GuiUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ public static Matrix4f getTransformationMatrix() {
2525
}
2626

2727
public static Matrix4f getTransformationMatrix(Matrix4f matrix4f) {
28-
floatBuffer.position(0);
28+
floatBuffer.rewind();
2929
getTransformationBuffer(floatBuffer);
3030
matrix4f.load(floatBuffer);
3131
return matrix4f;
3232
}
3333

3434
public static void setTransformationMatrix(Matrix4f matrix) {
35-
floatBuffer.position(0);
35+
floatBuffer.rewind();
3636
matrix.store(floatBuffer);
37-
floatBuffer.position(0);
37+
floatBuffer.rewind();
3838
GL11.glLoadMatrix(floatBuffer);
3939
}
4040

4141
public static void applyTransformationMatrix(Matrix4f matrix) {
42-
floatBuffer.position(0);
42+
floatBuffer.rewind();
4343
matrix.store(floatBuffer);
44-
floatBuffer.position(0);
44+
floatBuffer.rewind();
4545
GL11.glMultMatrix(floatBuffer);
4646
}
4747
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.cleanroommc.modularui.utils;
2+
3+
import net.minecraft.util.math.Vec3d;
4+
import net.minecraft.util.math.Vec3i;
5+
6+
import org.jetbrains.annotations.NotNull;
7+
import org.jetbrains.annotations.Nullable;
8+
import org.lwjgl.util.vector.Vector3f;
9+
10+
public class VectorUtil {
11+
12+
public static Vector3f set(Vector3f target, float x, float y, float z) {
13+
if (target == null) target = new Vector3f();
14+
target.set(x, y, z);
15+
return target;
16+
}
17+
18+
@NotNull
19+
public static Vector3f set(@Nullable Vector3f target, Vec3d vec) {
20+
return set(target, (float) vec.x, (float) vec.y, (float) vec.z);
21+
}
22+
23+
@NotNull
24+
public static Vector3f set(@Nullable Vector3f target, Vec3i vec) {
25+
return set(target, vec.getX(), vec.getY(), vec.getZ());
26+
}
27+
28+
public static Vector3f vec3f(Vec3d vec3d) {
29+
return set(null, vec3d);
30+
}
31+
32+
public static Vector3f vec3f(Vec3i vec3i) {
33+
return set(null, vec3i);
34+
}
35+
36+
public static Vector3f vec3fAdd(Vector3f source, Vector3f target, float x, float y, float z) {
37+
if (target == null) target = new Vector3f();
38+
if (source == null) return set(target, x, y, z);
39+
if (target != source) target.set(source);
40+
return target.translate(x, y, z);
41+
}
42+
43+
@NotNull
44+
public static Vector3f vec3fAdd(Vector3f source, @Nullable Vector3f target, Vec3i vec) {
45+
return vec3fAdd(source, target, vec.getX(), vec.getY(), vec.getZ());
46+
}
47+
48+
@NotNull
49+
public static Vector3f vec3fAdd(Vector3f source, @Nullable Vector3f target, Vec3d vec) {
50+
return vec3fAdd(source, target, (float) vec.x, (float) vec.y, (float) vec.z);
51+
}
52+
}

0 commit comments

Comments
 (0)