Everything posted by imadnsn
-
[1.13.2] replacing block.getActualState()
The method getActualState() no longer exists due to the flattening. Now you can either treat your states as blockstate like fences do, use extended states, or use TEs.
-
Random crash on world start up [1.10.2]
Minecraft.getMinecraft() is client-sided only, you use it in a field and a method that can get called in server
-
Client/Server Containers
You must remember that clients and servers can be on totally different physical places, you can't just let the server send an instance of the container to the client, they would only communicate through the network.
-
[SOLVED] Wait (x) seconds *WITHOUT PAUSING GAME*
Guess how Minecraft ticks? It's already in a loop, when the server gets launched, it gets into a snippet while (this.serverRunning) { // this is the server // This is where Minecraft server code happens, including running tick handlers' code every relevant tick depending on what they subscribed for, then it sleeps for at most 50 milliseconds before the loop goes on } This means that wherever you are in Minecraft, you are on a loop (one of 2 actually, one for server and one for client, but that's not the point). If a lot happens on the same tick, the game lags because the game loop doesn't go on. Forge added tick handling events so mods can run their code on each relevant tick, if modders want to tick without pausing the game they start counting their ticks (on a global variable you still didn't make) and each time the tick counter reaches certain amount the mod runs its code.
-
[1.10.2] directional blocks
You're most likely missing one of those methods look at the forge's documentation of blockstates here: http://mcforge.readthedocs.io/en/latest/blockstates/states/ I assure it will help you like it did to me.
-
black/purple icons in inventory(armor) [1.10]
Post the error that logs in the console. It wouldn't use the black and purple unless it either can't find the model or can't find the texture. So make sure your textures are at assets.modid.textures.items and at assets.modid.textures.armor (as you specified in your json file) and your model at assets.modid.models.item/plasticlegs.json (as you specified in setCustomModelResourceLocation). also unrelated but use setUnlocalisedName when registering your item so you can give it a name in gui
-
[SOLVED] [1.10.2] Player has stopped breaking block
using reflection with PlayerInteractionManager#isDestroyingBlock might work on server side, I'm not sure though PlayerInteractionManager of a player is in the public final field EntityPlayerMP#interactionManager
-
Date Value for Zombie head? (Crafting help)
he's trying to set an ItemStack with metadata I think, but no idea why not new ItemStack instead of putting its parameters and expecting it to magically work
-
[1.10.2] Thorns like behavior
If you want you can tidy it up by putting these conditions in a function that returns a boolean, where it returns false whenever any of the armor pieces isn't present. That won't make much of a change, however. As for the hurting, check if the entity is instance of EntityLivingBase (super class for all entities with health even players) then use EntityLivingBase#attackEntityFrom with DamageSource being DamageSource.causePlayerDamage(player)
-
[1.10] Check if block can be harvested and then harvest it without player object
Block#canHarvestBlock is used to check whether the player has the tool to break the block or fire a PlayerEvent.HarvestCheck if he doesn't have the required tool to check whether he can. other mods may have other implementations but that's the forge implementation in the Block class
-
[1.10.2][IBlockState][SOLVED] getStateFromMeta is deprecated. What should I use?
I know that in the block class it Block#getMetaFromState and Block#getStateFromMeta but I mean if you want to make a BlockState like you make a new ItemStack from somewhere else in the code, can't you use IBlockState#withProperty ?
-
[1.10.2][IBlockState][SOLVED] getStateFromMeta is deprecated. What should I use?
Shouldn't the easier way be by block.getDefaultState.withProperty(IProperty, value) ?
-
Items not being added to custom CreativeTabs
override Item.getSubItems(Item, CreativeTabs, List<ItemStack>) if you don't already, you return the list after adding all the sub-items of the item you are making so it can be shown in the creative tab
-
Spawning Ore in 1.10.2
We offer help for free here in this forum, don't ask for anything to give the answer. What you did is intolerable! As for op, A lot of things are quite similar but here's what you should change: Make sure the class implements IWorldGenerator The fifth parameter of generate should be of type IChunkGenerator not IChunkProvider world.provider.getDimensionType() instead of world.provider.dimensionId and the cases are DimensionType.NETHER , DimensionType.OVERWORLD and/or DimensionType.THE_END new WorldGenMinable() now takes IBlockState which would indicate the block and the metadata. It also takes IPredicate<IBlockstate> to get the blocks that can surround the ore, you can get that using BlockMatcher.forBlock(Blocks.STONE) WorldGenMinable#generate() takes BlockPos instead of x , y and z which is easily made by new BlockPos(x, y, z)
-
Making my Own Power [1.10.2]
if you mean then that's not java-related but explaining what you might want to do.
-
["1.9.4"]addInformation
replace import com.sun.org.apache.xml.internal.security.utils.I18n; with import net.minecraft.client.resources.I18n; since that the minecraft one
-
Why does game freezes with Entity.setFlag(7,true);? (for flying with elytra)
According to the code you posted, setFlagMethod is null when called, also, wouldn't it be easier that instead of using Class.forName("net.minecraft.entity.EntityLivingBase") that you just use EntityLivingBase.class ? I'm not sure that reflection is the only way here though. Edit: After looking at minecraft's code, setFlag(int, boolean) is for Entity not EntityLivingBase
-
render entity as a different one
The reason is when you r.doRender() it invokes the RenderLivingEvent.Pre event, so recursion happens, where the method keeps calling itself, until the stack overflows. I don't know how you'd fix it but maybe you'd have to render it yourself. If you look at RenderLivingBase, which your renderer extends, and look at its doRender(), you see the first line is public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) { // This is how forge invokes the event. if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre<T>(entity, this, x, y, z))) return; ..... }
-
[1.10.2] Animated model not updating in first person. (possibly bug)
Oh I thought that ItemStack overrides Object.equals() Then why don't you use isItemStackEqual() if you want strict equals or just compare the items because the same items are of the same instance.
-
[1.10.2] Animated model not updating in first person. (possibly bug)
that's why I said you should looks into the reason the stack.equals() returns false
-
[1.10.2] Animated model not updating in first person. (possibly bug)
I don't have an answer but maybe if you look into what is different between the stacks after you override Item::shouldCauseReequipAnimation() using debugging you may figure out a way to fix it. I believe it's either in the way stack.equals(otherStack) or entity.getHeldItemMainhand() / entity.getHeldItemOffhand() operate.
-
render entity as a different one
you didn't post the error message. Though I suspect it's something to do with client vs server, add a world.isRemote check
-
Blockstate file for texture variants?
I suggest you get a plugin for json editing on your IDE, it prevents things like those from happening
-
Blockstate file for texture variants?
"inventory": [{ }], look at the last comma, it's extra
-
[SOLVED] Security risks
Well not really, the thing is it's all about the implementation of the handling. If a mod decided to destroy the world when a client presses a button it will happen, but that's because it was hard-coded to do so. However, the way Minecraft works really gives the client little chance to do things. Almost everything that happens in the world where direct player interaction isn't needed (such as ticking tile entities) happens automatically on the server side. As a modder, one must always consider the first rule when handling packets, don't let the client be in control of doing big things directly.
IPS spam blocked by CleanTalk.