Even more work on the designer, last commit before I break everying
This commit is contained in:
parent
77102819a4
commit
ed5effb888
7 changed files with 77 additions and 23 deletions
|
@ -7,12 +7,15 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import reborncore.api.fuel.FluidPowerManager;
|
||||
import techreborn.api.recipe.RecipeHandler;
|
||||
|
||||
|
@ -85,6 +88,18 @@ public class TechRebornDevCommand extends CommandBase
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if ("getname".equals(args[0])) {
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
|
||||
Block block = Block.getBlockFromItem(player.getHeldItem(EnumHand.MAIN_HAND).getItem());
|
||||
if (block != null && block != Blocks.air) {
|
||||
sender.addChatMessage(new TextComponentString(GameData.getBlockRegistry().getNameForObject(block) + " with a meta of " + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
||||
} else {
|
||||
((EntityPlayer) sender).addChatComponentMessage(new TextComponentString("hold a Block!"));
|
||||
}
|
||||
} else {
|
||||
((EntityPlayer) sender).addChatComponentMessage(new TextComponentString("hold an item!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import javafx.scene.image.Image;
|
|||
import javafx.stage.Stage;
|
||||
import techreborn.manual.designer.fileUtils.SaveSystem;
|
||||
import techreborn.manual.designer.windows.MainWindowController;
|
||||
import techreborn.manual.saveFormat.Entry;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -64,13 +65,26 @@ public class ManualDesigner extends Application {
|
|||
boolean isValid = !SaveSystem.entries.containsKey(selectedItem);
|
||||
controller.textInput.setDisable(isValid);
|
||||
controller.nameTextArea.setDisable(isValid);
|
||||
controller.buttonMeta.setDisable(isValid);
|
||||
if(!isValid){
|
||||
if(SaveSystem.entries.containsKey(selectedItem)){
|
||||
Entry entry = SaveSystem.entries.get(selectedItem);
|
||||
if(entry.data != null && entry.data.data != null){
|
||||
if(entry.data.data.containsKey("text")){
|
||||
controller.textInput.setText(entry.data.data.get("text"));
|
||||
}
|
||||
//TODO Improve this
|
||||
} else {
|
||||
controller.textInput.setText("");
|
||||
}
|
||||
controller.nameTextArea.setText(entry.registryName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
controller.textInput.setDisable(false);
|
||||
controller.nameTextArea.setDisable(false);
|
||||
controller.buttonMeta.setDisable(false);
|
||||
|
||||
controller.image.setImage(new Image("assets/techreborn/textures/manual/gui/manual.png"));
|
||||
controller.image.setPreserveRatio(true);
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
package techreborn.manual.designer.fileUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.stage.FileChooser;
|
||||
import techreborn.manual.designer.ManualCatergories;
|
||||
import techreborn.manual.designer.ManualDesigner;
|
||||
import techreborn.manual.saveFormat.Entry;
|
||||
import techreborn.manual.saveFormat.ManualFormat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
||||
/**
|
||||
* Created by Mark on 05/04/2016.
|
||||
*/
|
||||
public class LoadSystem {
|
||||
|
||||
public static void load(){
|
||||
public static void load() throws FileNotFoundException {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle("Open master.json");
|
||||
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Jason File (*.json)", "*.json"));
|
||||
|
@ -20,6 +28,27 @@ public class LoadSystem {
|
|||
if(file != null){
|
||||
if(file.getName().endsWith(".json")){
|
||||
//Things
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
Gson gson = new Gson();
|
||||
ManualFormat format;
|
||||
format = gson.fromJson(reader, ManualFormat.class);
|
||||
System.out.println(format.entries);
|
||||
for(Entry entry : format.entries){
|
||||
System.out.println(entry.type);
|
||||
TreeItem parentTree = null;
|
||||
if(entry.category.equals(ManualCatergories.blocks.getValue())){
|
||||
parentTree = ManualCatergories.blocks;
|
||||
} else if(entry.category.equals(ManualCatergories.items.getValue())){
|
||||
parentTree = ManualCatergories.items;
|
||||
}
|
||||
if(parentTree == null){
|
||||
System.out.println("something bad happened");
|
||||
}
|
||||
TreeItem<String> newItem = new TreeItem<>(entry.name);
|
||||
parentTree.getChildren().add(newItem);
|
||||
parentTree.setExpanded(true);
|
||||
SaveSystem.entries.put(newItem, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import techreborn.manual.saveFormat.Entry;
|
|||
import techreborn.manual.saveFormat.EntryData;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
@ -33,7 +34,6 @@ public class MainWindowController {
|
|||
public TextArea textInput;
|
||||
public Button buttonDelete;
|
||||
public TextField nameTextArea;
|
||||
public Button buttonMeta;
|
||||
|
||||
public void newItem(Event event) {
|
||||
if(treeList.getSelectionModel().getSelectedItem() instanceof TreeItem){
|
||||
|
@ -50,7 +50,6 @@ public class MainWindowController {
|
|||
ArrayList<String> choices = new ArrayList<>();
|
||||
choices.add("Text");
|
||||
choices.add("Image");
|
||||
choices.add("Recipe");
|
||||
|
||||
ChoiceDialog<String> choiceDialog = new ChoiceDialog<>("Text", choices);
|
||||
choiceDialog.setTitle("Type?");
|
||||
|
@ -62,6 +61,7 @@ public class MainWindowController {
|
|||
Toolkit.getDefaultToolkit().beep();
|
||||
return;
|
||||
}
|
||||
entry.category = (String) item.getValue();
|
||||
item.getChildren().add(newItem);
|
||||
item.setExpanded(true);
|
||||
SaveSystem.entries.put(newItem, entry);
|
||||
|
@ -94,7 +94,12 @@ public class MainWindowController {
|
|||
}
|
||||
|
||||
public void open(ActionEvent actionEvent) {
|
||||
LoadSystem.load();
|
||||
try {
|
||||
LoadSystem.load();
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("bad things happened");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close(ActionEvent actionEvent) {
|
||||
|
@ -140,19 +145,9 @@ public class MainWindowController {
|
|||
if(SaveSystem.entries.containsKey(treeList.getSelectionModel().getSelectedItem())){
|
||||
Entry entry = SaveSystem.entries.get(treeList.getSelectionModel().getSelectedItem());
|
||||
if(entry != null){
|
||||
if(entry.data == null){
|
||||
entry.data = new EntryData();
|
||||
}
|
||||
if(entry.data.data == null){
|
||||
entry.data.data = new HashMap<>();
|
||||
}
|
||||
if(entry.data.data.containsKey("regName")){
|
||||
entry.data.data.replace("regName", nameTextArea.getText());
|
||||
} else {
|
||||
entry.data.data.put("regName", nameTextArea.getText());
|
||||
}
|
||||
entry.registryName = nameTextArea.getText();
|
||||
SaveSystem.entries.replace((TreeItem) treeList.getSelectionModel().getSelectedItem(), entry);
|
||||
}
|
||||
SaveSystem.entries.replace((TreeItem) treeList.getSelectionModel().getSelectedItem(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,10 @@ public class Entry {
|
|||
/**
|
||||
* This says what type of page it is, crafting, image, ect
|
||||
*
|
||||
* //TODO use class name?
|
||||
*/
|
||||
public String type;
|
||||
|
||||
public String category;
|
||||
|
||||
public EntryData data;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
<TextArea fx:id="textInput" layoutX="43.0" layoutY="8.0" maxWidth="250.0" prefHeight="59.0" prefWidth="250.0" AnchorPane.bottomAnchor="8.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="8.0" />
|
||||
<TextField fx:id="nameTextArea" layoutX="88.0" layoutY="25.0" />
|
||||
<Label layoutX="6.0" layoutY="29.0" text="Registry Name" />
|
||||
<Button fx:id="buttonMeta" layoutX="19.0" layoutY="59.0" mnemonicParsing="false" text="Set meta" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
"modId": "techreborn",
|
||||
"entries": [
|
||||
{
|
||||
"name": "Block",
|
||||
"name": "Quantum Chest",
|
||||
"registryName": "techreborn:techreborn.quantumChest",
|
||||
"type": "Text",
|
||||
"category": "Blocks",
|
||||
"data": {
|
||||
"data": {
|
||||
"text": "This is a block, it does things\n\nhow are new lines handled?",
|
||||
"regName": "minecraft:diamond"
|
||||
"text": "The quantum chest can store a lot of items"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue