Skip to content

Commit

Permalink
Fixed server side issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Jan 30, 2022
1 parent 6c22ed7 commit a2ac80e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ dependencies {
if (findProject(':titanium') != null) {
implementation project(':titanium')
} else {
implementation fg.deobf (project.dependencies.create('com.hrznstudio:titanium:1.18-3.4.0-27'))
implementation fg.deobf (project.dependencies.create('com.hrznstudio:titanium:1.18-3.4.1-31'))
}
runtimeOnly fg.deobf("team.chisel.ctm:CTM:1.18-+")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modGroup=com.buuz135.portality.Portality
api_version=3.3.1
api_version=3.3.2
modBaseName=portality
forgeVersion=1.12.2-14.23.4.2759
mcpVersion=stable_39
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
import com.hrznstudio.titanium.client.screen.addon.StateButtonInfo;
import com.hrznstudio.titanium.client.screen.asset.IAssetProvider;
import com.hrznstudio.titanium.component.button.ButtonComponent;
import com.hrznstudio.titanium.network.locator.ILocatable;
import com.hrznstudio.titanium.network.locator.instance.TileEntityLocatorInstance;
import com.hrznstudio.titanium.network.messages.ButtonClickNetworkMessage;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.Collections;
import java.util.List;
Expand All @@ -71,6 +71,7 @@ public PortalSettingButton(int posX, int posY, Supplier<Runnable> runnableSuppli
this.supplier = runnableSupplier;
}

@OnlyIn(Dist.CLIENT)
@Override
public List<IFactory<? extends IScreenAddon>> getScreenAddons() {
return Collections.singletonList(() -> new StateButtonAddon(this, infos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -70,11 +71,13 @@ public TextPortalButton setClientConsumer(Supplier<Consumer<Screen>> screenConsu
return this;
}

@OnlyIn(Dist.CLIENT)
@Override
public List<IFactory<? extends IScreenAddon>> getScreenAddons() {
return Collections.singletonList(() -> new TextButtonAddon(this, display, screenConsumer.get()));
}

@OnlyIn(Dist.CLIENT)
public class TextButtonAddon extends BasicButtonAddon {

private String text;
Expand Down
32 changes: 17 additions & 15 deletions src/main/java/com/buuz135/portality/tile/ControllerTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ public int getState() {
return 0;
}
}.setId(1));
this.addButton(new PortalSettingButton(-22, 12 + 22 * 3, () -> () -> {
OpenGui.open(3, ControllerTile.this);
}, new StateButtonInfo(0, PortalSettingButton.CHANGE_COLOR, "portality.display.change_color")) {
@Override
public int getState() {
return 0;
}
}.setId(5));
this.addButton(new TextPortalButton(5, 90, 80, 16, "portality.display.call_portal")
.setClientConsumer(() -> screen -> {
OpenGui.open(2, ControllerTile.this);
})
.setId(4)
.setPredicate((playerEntity, compoundNBT) -> PortalNetworkMessage.sendInformationToPlayer((ServerPlayer) playerEntity, isInterdimensional(), getBlockPos(), BlockPosUtils.getMaxDistance(this.getLength()), this.teleportationTokens))
);

this.addButton(new PortalSettingButton(-22, 12 + 22, () -> () -> {
}, new StateButtonInfo(0, PortalSettingButton.PUBLIC, "portality.display.make_private"), new StateButtonInfo(1, PortalSettingButton.PRIVATE, "portality.display.make_public")) {
Expand All @@ -138,21 +153,6 @@ public int getState() {
if (information.getOwner().equals(playerEntity.getUUID()))
setDisplayNameEnabled(!isDisplayNameEnabled());
}).setId(3));
this.addButton(new PortalSettingButton(-22, 12 + 22 * 3, () -> () -> {
OpenGui.open(3, ControllerTile.this);
}, new StateButtonInfo(0, PortalSettingButton.CHANGE_COLOR, "portality.display.change_color")) {
@Override
public int getState() {
return 0;
}
}.setId(5));
this.addButton(new TextPortalButton(5, 90, 80, 16, "portality.display.call_portal")
.setClientConsumer(() -> screen -> {
OpenGui.open(2, ControllerTile.this);
})
.setId(4)
.setPredicate((playerEntity, compoundNBT) -> PortalNetworkMessage.sendInformationToPlayer((ServerPlayer) playerEntity, isInterdimensional(), getBlockPos(), BlockPosUtils.getMaxDistance(this.getLength()), this.teleportationTokens))
);
this.addButton(new TextPortalButton(90, 90, 80, 16, "portality.display.close_portal").setPredicate((playerEntity, compoundNBT) -> closeLink()).setId(5));
}

Expand Down Expand Up @@ -384,6 +384,7 @@ public void linkTo(PortalLinkData data, PortalLinkData.PortalCallType type) {
}
PortalDataManager.setActiveStatus(this.level, this.worldPosition, true);
this.linkData = data;
markForUpdate();
}

public void closeLink() {
Expand All @@ -402,6 +403,7 @@ public void closeLink() {
linkData = null;
}
ChunkLoaderHandler.removePortalAsChunkloader(this);
markForUpdate();
}

public boolean isActive() {
Expand Down

0 comments on commit a2ac80e

Please sign in to comment.