-
Posts
5170 -
Joined
-
Last visited
-
Days Won
77
Everything posted by Choonster
-
You don't need the old player's thirst data after you've copied it to the new player in PlayeEvent.Clone, just use the new player's thirst data when sending the packet.
-
You shouldn't be catching IndexOutOfBoundsException, it should be allowed to propagate up to FML's exception handling and/or crash the game. It's only thrown when you've done something wrong that should be fixed. Is the IMessageHandler scheduling a task on the main thread to perform its action? Is it being called at all?
-
You're trying to send data to the server from the server, which makes no sense.
-
Use the Simple Network Implementation to send data between the client and server.
-
That code reaches across logical sides by accessing the server through the Minecraft class, which is client-only. It will also crash the dedicated server. Since FakePlayer extends EntityPlayerMP and requires a WorldServer, it should only be used from the logical server.
-
[1.10.2] Move item from hand to inventory slot from block
Choonster replied to Daeruin's topic in Modder Support
I'd suggest having a method on your TileEntity called something like insertHeldItem that takes an EntityPlayer and an EnumHand and attempts to insert the player's held item into the TileEntity's inventory. Use IItemHandler#insertItem to insert into a specific slot or ItemHandlerHelper.insertItemStacked to try and insert into the first slot possible, filling up existing stacks first. These both return the remaining ItemStack that couldn't be inserted (null in 1.10.2 or ItemStack.EMPTY in 1.11.2 if the full stack was accepted), so use EntityLivingBase#setHeldItem to replace the player's held item with this. -
Line 429 of RenderItem is the following: if (stack.getItem().showDurabilityBar(stack)) The only value that can be null on that line is the return of ItemStack#getItem, which means an ItemStack with a null Item is being rendered. The method is being called from GuiContainerCreative#drawTab, which draws the tab's icon ItemStack into the GUI. This means that the ItemStack with the null Item is the one you're returning from CreativeTabs#getIconItemStack. Creative tabs need to be initialised before items, so you can't pass an Item to a CreativeTabs constructor. Instead, override CreativeTabs#getTabIconItem or CreativeTabs#getIconItemStack (there's no need to override both) to get the Item from the the field it's being stored in (e.g. in your ModItems class).
-
Adding an entity other than a player to a team.
Choonster replied to SecondAmendment's topic in Modder Support
Your file probably wasn't encoded in or compiled as UTF-8. -
Adding an entity other than a player to a team.
Choonster replied to SecondAmendment's topic in Modder Support
Call TextFormatting#toString to get the formatting code of a TextFormatting value. If you're registering your event handler with EventBus#register, do it from the client proxy (or a client-only class called from it). If your mod is marked as client-only, you can reference client-only classes from anywhere and don't really need a proxy. If you're registering your event handler with the @Mod.EventBusSubscriber annotation, pass Side.CLIENT to it as an argument so it's only registered on the physical client. EntityJoinWorldEvent is fired when an entity is added the world. It should work in any event. Side note: Everything from the start of the quote in your second bullet point to the end of your post is formatted with a white background and black text, which looks quite ugly in the dark theme. I suggest you remove formatting when copying and pasting text into posts (or use Ctrl-Shift-V to paste without formatting). -
Adding an entity other than a player to a team.
Choonster replied to SecondAmendment's topic in Modder Support
That should work, but I'd recommend using TextFormatting instead of hardcoding the formatting code in the prefix string. I'd also recommend only setting the prefix when you create the team. Make sure you only add entities to the scoreboard on the client side (register the event handler from your client proxy or pass Side.CLIENT to @Mod.EventBusSubscriber [so it only runs on the physical client] and check that World#isRemote is true [so it only runs on the logical client]). What are you trying to do? -
Adding an entity other than a player to a team.
Choonster replied to SecondAmendment's topic in Modder Support
If you use the Scoreboard from the client World and enable glowing for the entity from EntityJoinWorldEvent, it will work without issue in single player and multiplayer. You should generally treat single player and multiplayer identically. Usually if something works in single player but not multiplayer, you've tried to reach across logical sides. Note that any changes to the team or its membership on the server side will overwrite the changes you've made on the client side. -
Don't implement IItemColor on your Item, it's a client-only interface and as such will crash the dedicated server if you reference it in common code. You need to create a completely separate implementation of it (e.g. with an anonymous class or lambda). You can't store the SingularityType in a field of your Item class unless you create and register an instance of the class for each SingularityType. You need to use the ItemStack's metadata value to get the SingularityType. You should store the colours as part of the SingularityType enum rather than using a giant switch statement to determine the colour.
-
As I said in your other thread, that method can add any entity to a team, not just players (despite the name). You shouldn't create a ScorePlayerTeam or a Scoreboard yourself. Use World#getScoreboard to get a World's Scoreboard and Scoreboard#createTeam to create a ScorePlayerTeam.
-
What exactly do you mean by a texture overlay? To colour an item model dynamically, register an IItemColor for the Item by calling ItemColors#registerItemColorHandler on Minecraft#getItemColors in init on the client side. The tint index passed to IItemColor#getColorFromItemstack tells you which part of the model is being rendered. For regular models, the tint index is manually specified for each face in the model. For models that extend builtin/generated, the tint index for each layerN texture is N.
-
You don't need MCPBot or SRG names for either of these. Use ScorePlayerTeam#setPrefix to set the team's prefix. The first TextFormatting code in the prefix string will be used as the glow colour of entities on the team.
-
Adding an entity other than a player to a team.
Choonster replied to SecondAmendment's topic in Modder Support
Use Scoreboard#addPlayerToTeam to add an entity (not just a player) to a team. Pass the entity's UUID string (Entity#getCachedUniqueIdString) as the player argument. If the team doesn't exist, you'll need to create it (Scoreboard#createTeam) before adding any entities to it. -
What do you actually need to do? Why do you require SRG names? MCPBot is documented here.
-
[Solved] Blockstates and item model for TileEntity
Choonster replied to Jay Avery's topic in Modder Support
It's an interface with a single method, implement it to return Collections#emptyMap. There's no need for a tutorial or example. Register it by calling ModelLoader#setCustomStateMapper on the client side in ModelRegistryEvent (if you're registering your Blocks/Items in RegistryEvent.Register) or preInit (if you're registering them in preInit). -
[Solved] Blockstates and item model for TileEntity
Choonster replied to Jay Avery's topic in Modder Support
You can fix this by registering an IStateMapper that returns an empty Map. I'm not too sure about this. -
The crash looks like this issue, which was fixed in Forge 1.11.2-13.20.0.2235. Update to the latest of version of Forge and it will either crash with a clearer message or not crash at all. However the root cause of the issue is the fact that your Block is being rendered as the missing model. The FML log will have an error in it stating exactly why this is, but I suspect it's because your Block has two properties that aren't accounted for in the blockstates file. To fix this, either register an IStateMapper for your Block to ignore those properties (recommended) or include them in your blockstates file (not recommended).
-
Entity#getEntityBoundingBox is the method you want, not Entity#getBoundingBox.
-
Override Block#getComparatorInputOverride to return the comparator output level stored in your TileEntity. When this level changes, call TileEntity#markDirty to notify Minecraft that the TileEntity's data has changed (so the chunk containing it won't be skipped when saving the world) and update the output level of adjacent comparators. The client shouldn't be involved in this, it will simply return 0 (the default value of an int) from Block#getComparatorInputOverride if the TileEntity's output level isn't synced (which is fine, since the server's level will be the one used by the comparator).
-
You cannot use Thread.sleep, that will pause the client or server thread completely and stop the game from running for the duration of the sleep. If you want to delay an action by a certain amount of time, you need to schedule a block update or count ticks in a ticking TileEntity or tick event handler. Why is the client telling the server to run a command? The server should be in charge of the game state (e.g. running commands) and send any data necessary for display purposes to the appropriate clients. The client doesn't need to know the comparator output level, it can simply return 0 while the server returns the actual value. You can't store mutable data in fields of your Block class, it's a singleton shared between all occurrences of the block. Mutable data must be stored in the block state or TileEntity.
-
[1.10.2] [SOLVED] Spawning particles in onBlockActivated
Choonster replied to Daeruin's topic in Modder Support
World#spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int...) does nothing on the server, it only spawns particles when called on the client. You need to use one of the spawnParticle overloads from WorldServer instead.