Skip to content

Commit

Permalink
Ported to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenDEV committed Mar 31, 2023
1 parent fee3d51 commit 88796fb
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 110 deletions.
10 changes: 10 additions & 0 deletions .idea/MCreatorLink.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions .idea/runConfigurations/Raspberry_Pi_Link.xml

This file was deleted.

6 changes: 3 additions & 3 deletions .idea/runConfigurations/runClient.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/runConfigurations/runServer.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ project.tasks.build.dependsOn project.tasks.shadowJar
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'official', version: '1.19.2'
mappings channel: 'official', version: '1.19.4'

runs {
client {
Expand Down Expand Up @@ -59,9 +59,10 @@ configurations {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'
minecraft 'net.minecraftforge:forge:1.19.4-45.0.39'

shadowpack 'com.fazecast:jSerialComm:2.7.0'
implementation 'com.fazecast:jSerialComm:2.7.0'
}

shadowJar {
Expand Down Expand Up @@ -121,7 +122,7 @@ task copyModIntoFinalBuild(type: Copy) {
from('build/libs/')
include ('mcreator_link-' + version + '-all.jar')
into('build/export/')
rename { "MCreator Link " + project.version + " [1.19.2].jar" }
rename { "MCreator Link " + project.version + " [1.19.4].jar" }
}

task copyDevModIntoFinalBuild(type: Copy) {
Expand All @@ -130,7 +131,7 @@ task copyDevModIntoFinalBuild(type: Copy) {
from('build/libs/')
include ('mcreator_link-' + version + '.jar')
into('build/export/')
rename { "MCreator Link " + project.version + " [1.19.2] - Dev.jar" }
rename { "MCreator Link " + project.version + " [1.19.4] - Dev.jar" }
}

task exportArduinoLibrary(type: Zip) {
Expand Down
29 changes: 11 additions & 18 deletions src/main/java/net/mcreator/minecraft/link/gui/GuiDirectLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@
* window resizes, the buttonList is cleared beforehand.
*/
@Override public void init() {
super.init();
super.init();

if (this.minecraft != null)
minecraft.keyboardHandler.setSendRepeatsToGui(true);

this.addRenderableWidget(connect = new Button(this.width / 2 - 100, this.height / 4 + 96 + 12, 200, 20,
Component.translatable("link.direct.connect"), e -> {
this.addRenderableWidget(connect = Button.builder(Component.translatable("link.direct.connect"), e -> {
String device = this.ipTextField.getValue();
RaspberryPi raspberryPi = RaspberryPiDetector.getRaspberryPiForIP(device);
if (raspberryPi != null) {
Expand All @@ -75,31 +71,28 @@
} else {
this.ipTextField.setTextColor(0xff5d4d);
}
}));
this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 120 + 12, 200, 20,
Component.translatable("gui.cancel"), e -> {
}).bounds(this.width / 2 - 100, this.height / 4 + 96 + 12, 200, 20).build());

this.addRenderableWidget(Button.builder(Component.translatable("gui.cancel"), e -> {
if (this.minecraft != null) {
this.minecraft.setScreen(this.lastScreen);
}
}));
}).bounds(this.width / 2 - 100, this.height / 4 + 120 + 12, 200, 20).build());

this.ipTextField = new EditBox(this.font, this.width / 2 - 100, 116, 200, 20, Component.literal(""));

connect.active = !this.ipTextField.getValue().isEmpty() && this.ipTextField.getValue().split(":").length > 0;
connect.active = !this.ipTextField.getValue().isEmpty() && this.ipTextField.getValue().split(":").length > 0;

this.ipTextField.setMaxLength(128);
this.addWidget(this.ipTextField);
this.ipTextField.setFocus(true);
}
this.ipTextField.setMaxLength(128);
this.addWidget(this.ipTextField);
this.ipTextField.setFocused(true);
}

/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
@Override public void onClose() {
super.onClose();
if (minecraft != null) {
minecraft.keyboardHandler.setSendRepeatsToGui(false);
}
}

/**
Expand Down
48 changes: 25 additions & 23 deletions src/main/java/net/mcreator/minecraft/link/gui/GuiListDevices.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import net.mcreator.minecraft.link.MCreatorLink;
import net.mcreator.minecraft.link.devices.AbstractDevice;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractSelectionList;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.navigation.ScreenDirection;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand Down Expand Up @@ -49,28 +49,30 @@ void refreshList() {
for (AbstractDevice device : MCreatorLink.LINK.getAllDevices()) {
GuiListDevicesEntry tmp;
this.addEntry(tmp = new GuiListDevicesEntry(this, device));
if (entry != null && device.equals(entry.getDevice()))
entry = tmp;
}

this.addEntry(devicesEntryScan);

if (entry != null)
super.setSelected(entry);
}

@Override protected void moveSelection(AbstractSelectionList.SelectionDirection ordering) {
this.moveSelection(ordering, entry -> !(entry instanceof GuiListDevicesEntryScan));
}

@Override public void setSelected(@Nullable GuiListDevicesEntry guiListDevicesEntry) {
super.setSelected(guiListDevicesEntry);
this.guiMCreatorLink.setSelectedDevice(this.getSelectedDevice());
}

/**
* Gets the width of the list
*/
if (entry != null && device.equals(entry.getDevice()))
entry = tmp;
}

this.addEntry(devicesEntryScan);

if (entry != null)
super.setSelected(entry);
}

@Override
protected GuiListDevicesEntry nextEntry(ScreenDirection direction) {
return this.nextEntry(direction, entry -> !(entry instanceof GuiListDevicesEntryScan));
}

@Override
public void setSelected(@Nullable GuiListDevicesEntry guiListDevicesEntry) {
super.setSelected(guiListDevicesEntry);
this.guiMCreatorLink.setSelectedDevice(this.getSelectedDevice());
}

/**
* Gets the width of the list
*/
@Override public int getRowWidth() {
return super.getRowWidth() + 85;
}
Expand Down
Loading

0 comments on commit 88796fb

Please sign in to comment.