Fix manual crashing the game, closes #1754

This commit is contained in:
modmuss50 2019-08-08 11:49:11 +01:00
parent 02c823986a
commit a08ee3d17a
4 changed files with 35 additions and 57 deletions

View file

@ -24,13 +24,17 @@
package techreborn.client.gui;
import net.minecraft.client.gui.screen.ConfirmChatLinkScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
import net.minecraft.util.SystemUtil;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.common.network.NetworkManager;
import techreborn.items.ItemManual;
import techreborn.packets.ServerboundPackets;
public class GuiManual extends Screen {
@ -52,11 +56,24 @@ public class GuiManual extends Screen {
@Override
public void init() {
int y = height / 4;
// buttons.add(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, I18n.translate("techreborn.manual.wikibtn")));
// buttons.add(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, I18n.translate("techreborn.manual.discordbtn")));
// if(ItemManual.allowRefund){
// buttons.add(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, I18n.translate("techreborn.manual.refundbtn")));
// }
addButton(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, I18n.translate("techreborn.manual.wikibtn"), var1 -> minecraft.openScreen(new ConfirmChatLinkScreen(t -> {
if(t){
SystemUtil.getOperatingSystem().open("http://wiki.techreborn.ovh");
this.minecraft.openScreen(this);
}
}, "http://wiki.techreborn.ovh", false))));
addButton(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, I18n.translate("techreborn.manual.discordbtn"), var1 -> minecraft.openScreen(new ConfirmChatLinkScreen(t -> {
if(t){
SystemUtil.getOperatingSystem().open("https://discord.gg/teamreborn");
this.minecraft.openScreen(this);
}
}, "https://discord.gg/teamreborn", false))));
if(ItemManual.allowRefund){
addButton(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, I18n.translate("techreborn.manual.refundbtn"), var1 -> {
NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
this.minecraft.openScreen(null);
}));
}
}
@Override
@ -76,48 +93,4 @@ public class GuiManual extends Screen {
}
}
// public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
// switch (button.id) {
// case 1:
// minecraft.openScreen(new ConfirmChatLinkScreen(this, "http://wiki.techreborn.ovh", 1, false));
// break;
// case 2:
// this.minecraft.openScreen(new ConfirmChatLinkScreen(this, "https://discord.gg/teamreborn", 2, false));
// break;
// case 3:
// minecraft.openScreen(null);
// NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
// break;
// }
// }
//
// @Override
// public void confirmResult(boolean result, int id) {
// switch(id) {
// case 1:
// if(result == true) {
// try {
// Desktop.getDesktop().browse(new java.net.URI("http://wiki.techreborn.ovh"));
// } catch (Exception e) {
// System.err.print(e);
// }
// }else {
// minecraft.openScreen(this);
// }
// break;
// case 2:
// if(result == true) {
// try {
// Desktop.getDesktop().browse(new java.net.URI("https://discord.gg/teamreborn"));
// } catch (Exception e) {
// System.err.print(e);
// }
// }else {
// minecraft.openScreen(this);
// }
// break;
// }
// }
// }

View file

@ -24,14 +24,17 @@
package techreborn.items;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import reborncore.common.registration.config.ConfigRegistry;
import techreborn.TechReborn;
import techreborn.client.gui.GuiManual;
public class ItemManual extends Item {
@ -45,9 +48,10 @@ public class ItemManual extends Item {
@Override
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player,
final Hand hand) {
throw new UnsupportedOperationException("1.13 fix me");
//player.openGui(TechReborn.INSTANCE, EGui.MANUAL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posY);
if(world.isClient){
MinecraftClient.getInstance().openScreen(new GuiManual(player));
}
//return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
}
}

View file

@ -35,13 +35,13 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.NetworkManager;
import techreborn.init.TRContent;
import techreborn.items.ItemManual;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
import techreborn.init.TRContent;
import techreborn.items.ItemManual;
import java.util.function.BiConsumer;
@ -126,8 +126,7 @@ public class ServerboundPackets {
if (stack.getItem() == TRContent.MANUAL) {
playerMP.inventory.removeInvStack(i);
playerMP.inventory.insertStack(new ItemStack(Items.BOOK));
//TODO 1.13
//playerMP.inventory.addItemStackToInventory(OreUtil.getStackFromName("ingotRefinedIron"));
playerMP.inventory.insertStack(TRContent.Ingots.REFINED_IRON.getStack());
return;
}
}

View file

@ -625,6 +625,8 @@
"techreborn.manual.discord": "Our discord",
"techreborn.manual.wikibtn": "Open",
"techreborn.manual.discordbtn": "Join",
"techreborn.manual.refund": "I want a refund",
"techreborn.manual.refundbtn": "Refund",
"_comment24": "Advancements",
"advancements.techreborn.root.desc": "Now that you have acquired Tech Reborn ore, you might find a tree tap usefull.",