Jump to content

3059673

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by 3059673

  1. And how do I use these tile's methods to notify client about nbt changes ?
  2. What way is correct to do the subject manipulation ? Just usual interaction like tile.doSuff() or via packets ? My case is tile's rendering class that implements TileEntitySpecialRenderer. It has my TileEntity class on input (renderAModelAt) . I need to do it so i can change my tile's rendering system, checking tile's nbt. But it always works incorrectly.
  3. How can i modify/control/add smth to player's 1st person/3d person view,draw custom thing on it ?
  4. I need some good,tested opengl tutorials . It would be better if they were minecraft ones.
  5. I wanna to fire event via my android device.
  6. I wanna to do some advanced stuff. Exactly what i need : Transport simple data(string) from minecraft to a website where this data will be saved . Then get this data when i want . Any ideas,ways to start from ? I don't really know how all that transportation stuff works . I don't know where to start from . I read this : http://docs.oracle.com/javase/tutorial/networking/urls/ . Do i need to make a webpage to save data ? Help me !!!
  7. I need to find a way to send some object (like EntityPlayer,itemStack,World - that kind of thing) via packets . As i can see in forge/vanilla object is chopped into byte array which then is sent via a packet. So how to do that ? If it's really complicated (cause i don't know how to work with bytes actually) , is there a good and neat way of transporting objects server-client vice versa . For now i just make a HashMap in my packethandler class which looks like that : String identifier (like player's username) and object to pass . But i think this method is too messy for a big packethandler class.
  8. Invoking the method on the wrong side..? Wut? You can't use some of the classes in multiplayer . Just think , how could you render something, use keyboard,mouse,open gui,etc on server ? All this should go to client . If you need to transport smth from client to server vice versa just use packets . There are some tuts for this if u need
  9. I think you are invoking the method on the wrong side
  10. Hey Everyone ! I've just started flicking through ForgeMultipart dev and i don't understand some stuff . Basically, i wanna make a MultiBlock but since ForgeMultipart is partially written in scala , it's not really understandable for me (i don't know scala :'( :'( :'( :'( :'() . Sooo maybe some good tuts ?
  11. where is minecraft || forge main packethandler class if there is one
  12. Do you know the path to forge's packethandler
  13. I managed this ;D ;D Just used FMLCommonHandler.instance().showGuiScreen(new SensorScreenGui(p.pc)); But don't actually know will it work in multiple
  14. GuiHandler : public class GuiHandler implements IGuiHandler { public static HashMap<EntityPlayer,Integer> indentifier = new HashMap(); public static HashMap<EntityPlayer,IComputerAccess> ssGui = new HashMap(); @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // TODO Auto-generated method stub if(ID == 1){ ItemStack stack = utils.getModularItemInInventory(player,"Power Fist"); if(stack != null && ModuleManager.itemHasActiveModule(stack, BagModule.NAME)){ int indentifier = 0; if(this.indentifier.containsKey(player)){ indentifier = this.indentifier.get(player); }else{ indentifier = utils.generateRandomInteger(); this.indentifier.put(player, indentifier); } if(stack.stackTagCompound.hasKey("bag")){ stack.stackTagCompound.getCompoundTag("bag").setInteger("indentifier",indentifier); }else{ stack.stackTagCompound.setCompoundTag("bag", new NBTTagCompound()); stack.stackTagCompound.getCompoundTag("bag").setInteger("indentifier",indentifier); } if(!stack.stackTagCompound.getCompoundTag("bag").hasKey("freq")){ stack.stackTagCompound.getCompoundTag("bag").setInteger("freq",1); } if(!stack.stackTagCompound.getCompoundTag("bag").hasKey(String.valueOf(stack.stackTagCompound.getCompoundTag("bag").getInteger("freq")))){ NBTTagCompound nbt1 = stack.stackTagCompound.getCompoundTag("bag"); NBTTagCompound nbt = new NBTTagCompound(); NBTTagList itemList = new NBTTagList(); nbt.setTag("Inventory", itemList); nbt1.setCompoundTag(String.valueOf(stack.stackTagCompound.getCompoundTag("bag").getInteger("freq")),nbt); stack.stackTagCompound.setCompoundTag("bag", nbt1); } return new ContainerBag(stack,player,indentifier); } //return new ContainerBag( null, null,null,player,1); }else if(ID == 2){ IInventory[] invs = utils.getPeripheralInventories(player, world); MovingObjectPosition spot = RemoteItem.getPlayerLookingSpot(player, false); if(spot != null && spot.typeOfHit != null){ switch(spot.typeOfHit){ case ENTITY: break; case TILE : if(world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ) != null && world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ) instanceof ChairTile){ return new ContainerPeripheral(invs[0],invs[1],(ChairTile) world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ)); } } } }else if(ID == 3){ return new SensorScreenGui(ssGui.get(player)); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 1){ ItemStack stack = utils.getModularItemInInventory(player, "Power Fist"); if(stack != null && ModuleManager.itemHasActiveModule(stack, BagModule.NAME)){ int indentifier = 0; if(this.indentifier.containsKey(player)){ indentifier = this.indentifier.get(player); }else{ indentifier = utils.generateRandomInteger(); this.indentifier.put(player, indentifier); } if(stack.stackTagCompound.hasKey("bag")){ stack.stackTagCompound.getCompoundTag("bag").setInteger("indentifier",indentifier); }else{ stack.stackTagCompound.setCompoundTag("bag", new NBTTagCompound()); stack.stackTagCompound.getCompoundTag("bag").setInteger("indentifier",indentifier); } if(!stack.stackTagCompound.getCompoundTag("bag").hasKey("freq")){ stack.stackTagCompound.getCompoundTag("bag").setInteger("freq",1); } if(!stack.stackTagCompound.getCompoundTag("bag").hasKey(String.valueOf(stack.stackTagCompound.getCompoundTag("bag").getInteger("freq")))){ NBTTagCompound nbt1 = stack.stackTagCompound.getCompoundTag("bag"); NBTTagCompound nbt = new NBTTagCompound(); NBTTagList itemList = new NBTTagList(); nbt.setTag("Inventory", itemList); nbt1.setCompoundTag(String.valueOf(stack.stackTagCompound.getCompoundTag("bag").getInteger("freq")),nbt); stack.stackTagCompound.setCompoundTag("bag", nbt1); } return new GuiBag(new ContainerBag(stack,player,indentifier)); } //return new GuiBag( null, null,null,player,1,new ContainerBag(null, null,null,player,1)); }else if(ID == 2){ IInventory[] invs = utils.getPeripheralInventories(player, world); MovingObjectPosition spot = RemoteItem.getPlayerLookingSpot(player, false); if(spot != null && spot.typeOfHit != null){ switch(spot.typeOfHit){ case ENTITY: break; case TILE : if(world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ) != null && world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ) instanceof ChairTile){ return new GuiPeripheral(invs[0],invs[1],(ChairTile) world.getBlockTileEntity(spot.blockX, spot.blockY, spot.blockZ)); } } } }else if(ID == 3){ return new SensorScreenGui(ssGui.get(player)); } return null; } Gui Registration : @EventHandler public void load(FMLInitializationEvent event) { //Recipes LoadStuff.loadRecipes(); // blockCheese = (ChairBlock) new ChairBlock(blockCheeseID,Material.wood).setCreativeTab(CreativeTabs.tabDecorations).setUnlocalizedName("Russoul's Peripheral"); russy = (Russy_Ore) new Russy_Ore(russyID,Material.rock).setCreativeTab(CreativeTabs.tabBlock).setUnlocalizedName("Russy ore"); itemBlasterRifle = new ItemBlasterRifle(this.itemBlasterRifleID).setUnlocalizedName("BlasterRifle").setCreativeTab(CreativeTabs.tabRedstone); itemBlasterBolt = new ItemBlasterBolt(this.itemBlasterBoltID).setUnlocalizedName("BlasterBolt").setCreativeTab(CreativeTabs.tabRedstone); TickRegistry.registerTickHandler(new MyTickHandler(EnumSet.of(TickType.PLAYER)), Side.SERVER); proxy.registerRenderers(); proxy.registerEvents(); EntityRegistry.registerModEntity(EntityBlasterBolt.class, "BlasterBolt", EntityRegistry.findGlobalUniqueEntityId(), this, 64, 10, true); GameRegistry.registerBlock(blockCheese,ItemBlock.class,"R_Peripheral",modID); GameRegistry.registerBlock(russy,ItemBlock.class,"Russy Ore",modID); LanguageRegistry.addName(itemBlasterRifle, "Blaster Rifle"); LanguageRegistry.addName(itemBlasterBolt, "Blaster Bolt"); LanguageRegistry.addName(blockCheese, "Russoul's Peripheral"); LanguageRegistry.addName(russy, "Russy Ore"); GameRegistry.registerTileEntity(ChairTile.class, "Russoul's_Peripheral"); GameRegistry.registerWorldGenerator(new MyGenerator()); NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler()); //LoadStuff.loadAspects(); LoadStuff.loadModules(); } openGui public class MyTickHandler implements ITickHandler{ private final EnumSet<TickType> ticksToGet; private static EntityPlayer tickedPlayer; public static HashMap<String,ArrayList<String>> key = new HashMap(); private static HashMap<Integer,IComputerAccess> events = new HashMap() ; private static HashMap<Integer,ChairTile> registeredIDs = new HashMap(); public static HashMap<String,String> mouse = new HashMap(); public MyTickHandler(EnumSet<TickType> ticksToGet) { this.ticksToGet = ticksToGet; } /* * I suggest putting all your tick Logic in EITHER of these, but staying in one */ @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { playerTick((EntityPlayer)tickData[0]); this.tickedPlayer = (EntityPlayer) tickData[0]; } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { key.clear(); mouse.clear(); } @Override public EnumSet<TickType> ticks() { return ticksToGet; } @Override public String getLabel() { return "TutorialPlayerTick"; } public static void playerTick(EntityPlayer player) { if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getDisplayName().equals("Power Fist")){ ItemStack stack = player.getCurrentEquippedItem(); for(int i = 0;i < ModuleManager.getRightClickModules().size();i++){ if(stack.stackTagCompound.hasKey("button")){ if(stack.stackTagCompound.getCompoundTag("button").hasKey(ModuleManager.getRightClickModules().get(i).getDataName())){ String key = stack.stackTagCompound.getCompoundTag("button").getString(ModuleManager.getRightClickModules().get(i).getDataName()); if(utils.isKeyPressed(player.username) && utils.whatKeyIsPressed(player.username).equals(key)){ if(ModuleManager.getRightClickModules().get(i).getDataName() == "Remote"){ MovingObjectPosition spot = RemoteItem.getPlayerLookingSpot(player, false); new RemoteModule(LoadStuff.TOOLONLY).onRightClick(player, player.worldObj, stack); }else if(ModuleManager.getRightClickModules().get(i).getDataName() == "Blink Drive"){ new BlinkDriveModule(LoadStuff.TOOLONLY).onRightClick(player, player.worldObj, stack); } } } } } } if(!registeredIDs.isEmpty()){ for(int j = 0;j<300;j++){ if(registeredIDs.containsKey(j)){ //for(int i = 0;i<keys.length;i++){ if(registeredIDs.get(j) != null){ String Username = registeredIDs.get(j).Username; if(Username != null){ if(player != null && player.username.equalsIgnoreCase(Username)){ ItemStack stack = utils.getModularItemInInventory(player, "Power Fist"); if(stack != null){ if(ModuleManager.itemHasModule(stack, RemoteModule.NAME)){ if(utils.isKeyPressed(player.username)){ IComputerAccess pc = getEvent(j); try{ pc.queueEvent("My_Key_Event", new Object[]{utils.whatKeyIsPressedForMyKeyEventComputerCraftStuff(player.username)}); unregister(j); }catch(Exception e){ e.printStackTrace(); } } } } } } } //} } } } if(utils.getModularItemInInventory(player, "Power Fist") != null){ ItemStack stack = utils.getModularItemInInventory(player, "Power Fist"); if(utils.isKeyPressed(player.username) && utils.whatKeyIsPressed(player.username).contains("Z")){ if(stack != null && stack.getItem().equals(ModularPowersuits.powerTool)){ if(stack.stackTagCompound != null){ if(stack.stackTagCompound.hasKey("PeripheralPassword")){ utils.chat(player, "has not key"); String ind = stack.stackTagCompound.getString("PeripheralPassword"); ChairTile p = utils.getChairTileWithEniqueIndentifier(player.worldObj, player.username, ind,player); if(p != null){ utils.chat(player, "p ! null"); if(p.pc != null){ utils.chat(player, "p.pc ! null"); GuiHandler.ssGui.put(player, p.pc); //player.openGui(Main.instance, 3, player.worldObj,(int) player.posX,(int) player.posX,(int) player.posX); FMLCommonHandler.instance().showGuiScreen(new SensorScreenGui(p.pc)); } } } } } } } } public static void openPC(TileEntityComputer Computer,String Username){ EntityPlayer player = tickedPlayer; if(Computer instanceof TileEntityComputer && player.username.equalsIgnoreCase(Username)){ Computer.getBlockType().onBlockActivated(Computer.worldObj, Computer.xCoord, Computer.yCoord, Computer.zCoord, player, 0, 0, 0, 0); player.openGui(OpenPeripheral.instance, OpenPeripheral.Gui.remote.ordinal(), Computer.worldObj, Computer.xCoord, Computer.yCoord, Computer.zCoord); } } public static IComputerAccess getEvent(int id){ return events.get(id); } public static void register(int id,ChairTile tile, IComputerAccess pc){ events.put(id, pc); registeredIDs.put(id,tile); } public static void unregister(int id){ events.remove(id); registeredIDs.remove(id); } public static HashMap<Integer,ChairTile> getRegisteredIDs(){ return registeredIDs; } public static void setKeyPressed(String player,String key1){ if(!key.containsKey(player)){ ArrayList<String> array = new ArrayList(); array.add(key1); key.put(player, array); }else{ ArrayList<String> array = key.get(player); array.add(key1); key.put(player, array); } } public static void setMousePressed(String player,String mouse1){ mouse.put(player, mouse1); }
  15. EntityPlayer.openGui doesn't work for me . One more thing . Its just GuiScreen not GuiContainer . So what should i return in getServerGuiElement ? if null that doesn't work .
  16. my code is : if(utils.getModularItemInInventory(player, "Power Fist") != null){ // get MPS power fist from player's inv ItemStack stack = utils.getModularItemInInventory(player, "Power Fist"); //get MPS power fist from player's inv if(utils.isKeyPressed(player.username) && utils.whatKeyIsPressed(player.username).contains("Z")){ // if key is pressed (server side remake) if(stack != null && stack.getItem().equals(ModularPowersuits.powerTool)){//more check,actually not needed if(stack.stackTagCompound != null){ //more check,actually not needed if(stack.stackTagCompound.hasKey("PeripheralPassword")){ utils.chat(player, "has key"); String ind = stack.stackTagCompound.getString("PeripheralPassword"); ChairTile p = utils.getChairTileWithEniqueIndentifier(player.worldObj, player.username, ind,player); //my code for getting peripheral by username and enique id if(p != null){ utils.chat(player, "p ! null"); if(p.pc != null){ // it's actually the computercraft peripheral utils.chat(player, "p.pc ! null"); PacketHandler.ssGui1.put(player.username, player); PacketHandler.ssGui2.put(player, p.pc); SimplePacket sp = new SimplePacket("ssGui",player.username); sp.sendPacketTo(Where.PLAYER, player); //what i need here is to send packet to client to tell it to open guiscreen //But that doesn't work (i use Modloader.openGUI(EntityPlayer,GuiScreen)) //is there anyway to open it on server ? //if no is IPacketHandler used for both client and server packets ? //how to corretly use it as client packethandler } } } } } } }
  17. Already figured out I did smth like this : got world obj , got all tiles in that world obj , listed through to my one (instance) than checked for enique endentifier (that i had set before) if equals == happiness
  18. Actually what i want is getting TileEntity without coordinates (world.getBlockTileEntityAt(x,y,z)) . If there is no way doing it , how can i reach this with smth like ... registering it somehow with string indentifier to somewhere and then getting it with this string ? Edit : P.S the cause i need it with coords is redstone in motion mod
  19. My goal is to coordinates free get a ComputerCraft pc via a peripheral that is connected to a player via username of a player . my Peripheral - http://pastebin.com/W66mqwrE my Tick handler - http://pastebin.com/43YfR7NZ my mod - https://dl.dropboxusercontent.com/u/90281575/Rs%20mod.zip(you will need a lot of external mods : required-after:powersuits;required-after:complexmachines;required-after:Mekanism;after:PowersuitAddons;required-after:ComputerCraft;required-after:OpenPeripheral" To launch mod drop this - https://dl.dropboxusercontent.com/u/90281575/ToolModel.class to Powersuits jar/net/machinemuse/powersuits/client/render/item all works fine BUT if i have 2 or more of these peripherals ComputerCraft event goes only to the first pc(that was activated before athers) Any help ?
  20. *Mazetar, thanks I have one more question about packet. Is there a way of sending some complex data like ItemStack or EntityPlayer via packets ?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.