Jump to content

gpouliot

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by gpouliot

  1. It's turns out that using the render tick events actually works really well for me. For a workable mod that is supposed to be played by people, not so much. For my video capture purposes, it works great. In fact, it's better now. I can individually build blocks at 120 (or more) individual block placements per second instead of just 20...
  2. I've got a crazy solution. You're welcome to talk me out of it... For this mod that will only be used by me under controlled conditions, I think I might just be able to get away with managing everything under the render tick event...
  3. I'm looking for ideas on what direction I should take, not necessarily a specific answer. Long story short: I'm managing building pre-recorded structures during server tick events and doing pre-recorded player movements during render tick events (to get smooth motion). Although I can mostly get things synced up and consistent, the player movements are dependent on performance and get out of sync with structure building if conditions change (like when I try to record things with video capture software). Any thoughts on how best to get the camera (player) from point A to point B in a specific amount of server ticks while still having it be smooth? Long story long: I made a mod which lets me record block placement and then playback the recordings. I can adjust the playback speed, number of copies, location etc. The playback process is handled during SeverTickEvents. In addition to this, I am able to move the camera (the player) to and between set locations during RenderTickEvents . The idea is to build structures while the camera moves around to set locations. The problem is that while structure building is not dependent on performance (it's pretty consistent because it's based on server ticks) the player movement is based on performance. I figured that I could manage with this because the results were "consistent" (given the same conditions). However, the moment I tried to start recording the results using video capture software, the player movements and structure building quickly got out of sync. Possible Fixes: - I was thinking that I could time player movements based on server ticks (ex. Move player from A to B in 20 ticks) but keep track of the average number of render ticks per per server tick (based on current performance) and update the players location exactly 3 times per server tick (to accommodate 60fps recording). For example, if there was 30 render ticks during the last server tick, I would update the player's location every 10 render ticks during the next server tick. I'm not really sure if I can do this smoothly without judder and inconsistent movements. - A more extreme solution (which I hope I don't have to implement) would be to try and render everything offline like some recording mods do. I hope that there's an easier solution. Any thoughts? Am I making things more complicated than it should be?
  4. Thanks.. I thought I'd have to get all fancy and capture changes as they happened. However, simply comparing my saved Blocks to the world state and updating them just before saving them did the trick. Something that I thought was going to be complicated was accomplished with 1 line of code.
  5. Can someone point me in the right direction? I've made mod to record and playback block placements based on PlaceEvents and BreakEvents. Now, I want to update my recordings if the player places a block (like a repeater or comparator) and then updates the block (changes tick count, turns lever on, opens or closes a door). Is there an event that fires when these things happen?
  6. Using the meta data did the trick. The code below produces the correct IBlockState. Please note that the code below does not do any error checking. It's just a proof of concept to access the meta data of a player inventory item. Code is needed to check that the inventory slot has something in it and that the item can be converted to a block. Block testBlock = Block.getBlockFromItem(player.inventory.mainInventory[0].getItem()); int a = player.inventory.mainInventory[0].getMetadata(); sender.addChatMessage(new TextComponentString(TextFormatting.GREEN + "Meta Data " + testBlock.getStateFromMeta(a)));
  7. The code was just an example. I will only be processing valid items.
  8. I want to place blocks (like colored wool) in my players hotbar and then make use of those items in my code. Using code similar to below, I can easily generate a block or IBlockState from an item in the players Inventory. However, I haven't been able to get the properties. For example, if the item in question is a piece of colored wool, my code below only generates a white piece of wool. Does anyone know how to figure out the properties of an item in a players Inventory? I know how to set the properties, I simply don't know how to figure out what the properties of an Item are. Item testItem = player.inventory.mainInventory[0].getItem(); Block testBlock = Block.getBlockFromItem(player.inventory.mainInventory[0].getItem()); IBlockState iState = testBlock.getDefaultState();
  9. I've written out some Break and Place events to a text file in order to load them and try to recreate the break and place events. My intention is to record me building things and then be able to replay or rewind the building process. Using the example below, I can easily load in the data and create a sandstone block by using this command (the "minecraft:sandstone" would be a variable in the actual code): Block b = BlockgetBlockFromName("minecraft:sandstone"); However, I'm at a loss as to how to convert the [type=sandstone] text into usable blockstate properties (IProperties). Put another way, I can recreate the block in question but can't figure out how to set the properties. I imagine that it's either simple or I'm going about things the wrong way. Can anyone offer some insight or an example? Example line in my text file: BlockType: minecraft:sandstone[type=sandstone] X:488 Y:55 Z:62 Type: Break
  10. That's pretty much what I thought. Back to banging my head against a wall..
  11. I'll put a little code here to better show what I'm up against... The three classes below do the lion's share of the work. What makes them so easy and nice to work with is the fact that I don't have to create any BlockEvents myself. When an event happens I simply add it to the list. When I want to play or rewind the list, I simply iterate through the list and use setBlockState to make the needed changes. Since I can't directly save and then reload BlockEvent's (that would be nice), I think I have to pull out the needed data, save it, reload it and then somehow create my own list of BlockEvents based on that loaded data. It's much more complicated than simply adding existing block events to a list and replaying them when needed. Alternatively, I'm thinking that instead of using a list of BlockEvents, maybe the better option is to create my own list with a custom data format that only stores the block position, block type, metadata and event type (place or break). That way, saving and reloading the data would be relatively easy. The only tricky part is making sure I properly handle the meta data and figure out how to correctly send the needed state information in the second argument of the setBlockState() command. If anyone has done something similar, I'd love to see an example... public void record(BlockEvent event) { if(isRecording == true) { if(event instanceof BreakEvent || event instanceof PlaceEvent) { events.add(event); } } } public void play(EntityPlayer player) { if(!events.isEmpty()) { for(BlockEvent event : events) { if(event instanceof BreakEvent) { player.worldObj.setBlockState(event.getPos(), Blocks.AIR.getDefaultState()); } else if(event instanceof PlaceEvent) { player.worldObj.setBlockState(event.getPos(), ((PlaceEvent) event).getState()); } } } } public void rewind(EntityPlayer player) { if(!events.isEmpty()) { ListIterator li = events.listIterator(events.size()); while(li.hasPrevious()) { Object current = li.previous(); if(current instanceof BreakEvent) { player.worldObj.setBlockState(((BlockEvent) current).getPos(), ((BlockEvent) current).getState()); } else if(current instanceof PlaceEvent) { player.worldObj.setBlockState(((BlockEvent) current).getPos(), ((PlaceEvent) current).getBlockSnapshot().getReplacedBlock()); } } } }
  12. I guess where I'm getting hung up is the meta data. If it wasn't for the meta data, I would just save the x,y,z coordinates, whether it was a place or break event and what type of block it is or was. However, given that there is all sorts of meta data to contend with, I'm just having trouble wrapping my head around it.
  13. I'm working on a mod to Record and then playback block events. Specifically, it records place events and break events and then lets me replay the events either in forward or reverse order. I've got that working simply by making a list of block events and adding the break or place events to the list as they occur. It's then trivial to replay the events. Now, I'm at the point where I want to save these block event lists to disk so that I can load them and recreate the block events at a later date. When it comes to Java, I'm a little rusty so I was trying to find an example that I could work with. However, most tutorials are about creating new block types. There doesn't seem to be a lot of examples of people wanting to save block events to disk (and then reload them). As a test, when I run my Stop Recording command, it opens a file (in the Minecraft game world directory) and writes the x,y,z coordinates of the effected blocks. That's easy. Where I'm getting hung up is on the best way to go from a BlockEvent to a Text File and then back to a Block Event when I reload the data. Does anyone know of any examples that might help? Baring that, what would you guys suggest? I don't need someone to do it for me, just point me in the right direction and I can take it from there. Thanks.
×
×
  • Create New...

Important Information

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