Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.6.4] Why world.isRemote is always true?


BlackCrafer666
 Share

Recommended Posts

HELLo

    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
            System.out.println(world.isRemote); // true / false
        ++shot;
        if (shot>5){
            System.out.println(world.isRemote); // always true
            player.inventory.consumeInventoryItem(mod.item2.itemID);
            shot = 0;
        }
        System.out.println("shot="+shot);
        return stack;
}

Why world.isRemote is always true?

Link to comment
Share on other sites

Looks to me like you made 'shot' both a class field in your Item class and probably 'static' on top of that. Oops on both counts. You should store the number of shots fired in the ItemStack's NBT and your problem with isRemote will probably fix itself.

 

Is that piece of code the only place you use the 'shot' variable?

Link to comment
Share on other sites

Looks to me like you made 'shot' both a class field in your Item class and probably 'static' on top of that. Oops on both counts. You should store the number of shots fired in the ItemStack's NBT and your problem with isRemote will probably fix itself.

 

Is that piece of code the only place you use the 'shot' variable?

 

I'm curious on how you set an itemStacks NBT (this is how you can keep certain information privy to each item stack right?) however I keep getting null exceptions and other types of errors. How does one use this properly? If there is a good tutorial on it please link me.

Link to comment
Share on other sites

since no-one has actually answered your question i will

 

onItemRightClick is called by the client only when you right click with an item

the client will always returns true because it is connected to either a local-server task(started by the singleplayer client) or a server

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • im trying to run a modern rlcraft server but it wont even start. this is the log C:\Users\soto5\Downloads\Modern+RLCraft+Server+Pack-1.12.2-1.5.2\Modern RLCraft Server Pack-1.12.2-1.5.1>java -Xmx4096M -Xms4096M -jar forge.jar nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more    
    • Is there a way to "override" an entity's texture to something else without creating a "dummy" item when using ThrownItemRenderer? I tried creating a Renderer that extends it with a ResourceLocation override but this does not change the entity's 2D texture. Any help would be appreciated. Render class: public class BulletEntityRenderer extends ThrownItemRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation(ExampleMod.MOD_ID, "textures/entity/bullet.png"); public BulletEntityRenderer(EntityRendererProvider.Context context) { super(context); } @Override public ResourceLocation getTextureLocation(Entity entity) { return TEXTURE; } } Render registry: public class ModRender { public static void registerRender() { EntityRenderers.register(ExampleMod.BULLET, BulletEntityRenderer::new); } } Entity class: public class BulletEntity extends ThrowableItemProjectile { private float damage = 12.0F; private int pierceLevel = 0; private int ticksAlive = 0; private final int lifespan = 60; public BulletEntity(EntityType<BulletEntity> type, Level world) { super(type, world); } public BulletEntity(Player player, Level world, float damage, int pierceLevel) { super(ExampleMod.BULLET, player, world); this.damage = damage; this.pierceLevel = pierceLevel; this.setNoGravity(true); } public DamageSource causeBulletDamage(BulletEntity bullet, Entity attacker) { return (new IndirectEntityDamageSource("bullet", bullet, attacker)).setProjectile(); } public void tick() { super.tick(); Vec3 vec3d = this.getDeltaMovement(); double d1 = vec3d.x; double d2 = vec3d.y; double d0 = vec3d.z; if (this.isInWater()) { this.level.addParticle(ParticleTypes.BUBBLE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } else { this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } if (ticksAlive > lifespan) { this.discard(); } ticksAlive++; } @Override protected void onHitEntity(EntityHitResult hitResult) { LivingEntity target = (LivingEntity) hitResult.getEntity(); Entity shooter = getOwner(); double armor = target.getArmorValue() * (1 - (0.2 * pierceLevel)); double toughness = target.getAttribute(Attributes.ARMOR_TOUGHNESS).getValue(); float finalDamage = (float) (damage * (1 - (Math.min(20, Math.max((armor / 5), armor - ((4 * damage) / (toughness + 8))))) / 25)); target.hurt(causeBulletDamage(this, shooter).bypassArmor(), finalDamage); } @Override public Item getDefaultItem() { return ModItems.BULLET; } }
    • Which version of Forge did you use? Post debug log
    • delete this client config file
    • Latest minecraft most viewed youtube video! Here's the link : https://shrinke.me/SCMUI
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.