Jump to content

Autom

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Autom's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Focusing on clouds for the moment and found the minecraftforge.client.CloudRenderer and the method setCloudRenderer in WorldProvider, but am a little unclear on what to do with them as setCloudRenderer takes an IRenderHandler and CloudRenderer is just implements an interface called IResourceManagerReloadListener with no apparent way to cast or convert them. Monitoring the WorldProvider at runtime it seems the cloud renderer is always null anyway so I don't think this is the right thing. A CloudRenderer is set in FMLClientHandler, but this just uses the WorldProvider method.
  2. I am attempting to modify some of the vanilla mechanics- currently clouds and difficulty, and if that works well potentially more complicated things like rain and the day/night cycle, but clouds and the difficulty system are the main ones. I think the clouds would be possible if I replaced the CloudRenderer class with a duplicate of my own design and the difficulty if I was able to override the World method getDifficultyForLocation(BlockPos pos). However, the only way I can think to do that is through ASM, which rarely ends well. Is there another way to gain access to the logic I am trying to influence that is less hackish, or an approved/safe way to do it via ASM? (If it matters I am planning to have the contents of a hash table reflect the presence of a block in nearby chunks- then clouds will render differently or the difficulty will be changed in those areas. Since there are only so many chunks loaded at a time this should not have too much of an adverse impact on performance.)
  3. UPDATE: Doing the above actually causes some weird concurrency issues when automation is adding items while the player is taking them away, resulting in temporary duplication of items. To have a slot that presents different options to players and automation, one needs to make a separate handler class for each type of capability and have the more restrictive ones wrap the least restrictive one to control what can be done to it. The determination of which handler to provide then needs to be made in getCapability(). The implementation is very similar to what is discussed here.
  4. Got it working; I ran into a bit of a hiccup when I realized there are some slots I want the player to do something with (usually extract from) but not automation. However, this was solved by giving the ItemStackHandler classes a member to determine whether they were being accessed by the player or by automation, and setting that when they were passed through the TileEntity's getCapability() method. There are probably other ways to do that, but this is my preferred version due to being lightweight and simple.
  5. I'm attempting to make a tile-entity inventory slot that permits only one instance of a single item (specifically, an anvil), and have not been having much success. Creating an AnvilSlot class which extends ItemSlotHandler and overriding the method public boolean isItemValid(ItemStack stack) { return stack.getItem() instanceof ItemAnvilBlock; } causes non-anvil items to be rejected through the GUI while accepting anvils just fine, but dispensers and other automation tools will crash the server upon attempting to insert any item at all: Furthermore, I'm not entirely sure how to go about reducing the size of the slot to 1: I tried checking against this.getHasStack() such that it would only accept if the slot was empty, but the number of anvils I could put into the slot via GUI remained 64. I'm using a TileEntity that implements ICapabilityProvider (and ITickable), and a container that extends the base Container class.
  6. I've created a tile entity that (through the consumption of bottles-o-enchanting placed in its inventory) maintains an 'experience level' internal to itself. It seems to be working fine, until the game is closed and reloaded- then the level has been reset to zero. My understanding was that overriding the ReadFromNBT and WriteToNBT methods would allow the level data to be saved, as indeed that seems to be all that is required to save the items: @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.getSizeInventory(); ++i) { if (this.getStackInSlot(i) != null) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); this.getStackInSlot(i).writeToNBT(stackTag); list.appendTag(stackTag); } } nbt.setTag("Items", list); NBTTagInt lev = new NBTTagInt(level); nbt.setTag("level", lev); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); } this.level = nbt.getInteger("level"); } Is this really all that is required? More broadly, is any modification or implementation of a network manager required to keep something like this synchronized between clients and servers? There don't seem to be many good tutorials on this subject that don't point to dead source code, etc., and looking at other mods has left me more confused than enlightened by the variety of implementations used.
×
×
  • Create New...

Important Information

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