Jump to content

MC 1.10+ How to use instanceof in 1.10+ ?


winnetrie

Recommended Posts

I'm trying to use instanceof but it gives me an error.

I could use it in the exact same way in 1.7.10 but in 1.10.2 it give me this error:

 

Syntax error on token "instanceof", delete this token for instanceof

BlockStairs cannot be resolved to a variable for BlockStairs

 

this is the code for my glass stairs:

@SideOnly(Side.CLIENT)
    public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
    {
        IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
        Block block = iblockstate.getBlock();
        
	return block==this || block == instanceof BlockStairs;

        
    }

Link to comment
Share on other sites

#BasicJava

  • Haha 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

lol omg, i know this and i don't know why i did that.

I already compared it with my 1.7.10 mod code and couldn't understand why it is working there and not here.

#facepalm

Try programming only with Java before getting into mods so you don't confuse basic Java things with forge modding things

Link to comment
Share on other sites

Try programming only with Java before getting into mods so you don't confuse basic Java things with forge modding things

 

It's both java so you can't get confused about this "block instanceof Block", because it stays the same.

I Know this is wrong "block == instanceof Block" but it seems i looked over it.

I even don't know why i did that, it doesn't make sense. I guess i was tired at that moment!

It's not only basic java but also basic other languages like c++.

But at some point you are right, i will some day try to program something in java. Sounds very intresting!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been having trouble launching forge 1.19.4, i watched YouTube videos but i still don't have a solution.
    • This is my code: private void addCreative(Register<Block> event) { if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS) event.register(EXAMPLE_BLOCK); } Cannot resolve symbol 'Register'   How do I fix? I have tried the import import net.minecraftforge.registries.Register; but it doesn't work.   I also have these problems on that same code: Cannot resolve method 'getTab()' Cannot resolve method 'register(RegistryObject<Block>)'
    • my arrow wont move at all it would stay mid air and show no collision   my Entity class: package net.jeezedboi.epicraft.entity.custom; import net.jeezedboi.epicraft.init.ModItems; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.IPacket; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; public class ExplosiveArrowEntity extends AbstractArrowEntity { // default constructor, required to register the entity public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, World world) { super(entityType, world); } public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, double x, double y, double z, World world) { super(entityType, x, y, z, world); } // the constructor used by the ArrowItem public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, LivingEntity shooter, World world) { super(entityType, shooter, world); } // the item stack to give the player when they walk over your arrow stuck in the ground @Override protected ItemStack getArrowStack() { return new ItemStack(ModItems.EXPLOSIVE_ARROW.get()); } @Override protected void onEntityHit(EntityRayTraceResult result) { super.onEntityHit(result); // this, x, y, z, explosionStrength, setsFires, breakMode (NONE, BREAK, DESTROY) this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 4.0f, true, Explosion.Mode.BREAK); } // called each tick while in the ground @Override public void tick() { if (this.timeInGround > 60){ this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 4.0f, true, Explosion.Mode.BREAK); this.remove(); } } // syncs to the client @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } my item class :   package net.jeezedboi.epicraft.item.custom; import net.jeezedboi.epicraft.entity.custom.ExplosiveArrowEntity; import net.jeezedboi.epicraft.init.ModEntityTypes; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.ArrowItem; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ExplosiveArrowItem extends ArrowItem { public ExplosiveArrowItem(Properties props) { super(props); } @Override public AbstractArrowEntity createArrow(World world, ItemStack ammoStack, LivingEntity shooter) { ExplosiveArrowEntity explosiveArrowEntity = new ExplosiveArrowEntity(ModEntityTypes.EXPLOSIVE_ARROW.get(), shooter, world); return explosiveArrowEntity; } } other stuffs: public static final RegistryObject<Item> EXPLOSIVE_ARROW = ITEMS.register("explosive_arrow", () -> new ExplosiveArrowItem(new Item.Properties().group(ModItemGroup.Epic_Items))); public static final RegistryObject<EntityType<ExplosiveArrowEntity>> EXPLOSIVE_ARROW = ENTITY_TYPES.register("explosive_arrow", () -> EntityType.Builder.create((EntityType.IFactory<ExplosiveArrowEntity>) ExplosiveArrowEntity::new, EntityClassification.MISC) .size(0.5F, 0.5F).build("explosive_arrow")); mappings channel: 'snapshot', version: '20210309-1.16.5'
    • may i ask what it was that fixed it, I'm having the same problem and its frustrating because I'm making an origin.
    • I need to accesses byPath field of net.minecraft.client.renderer.texture.TextureManager. As I found out I need to use accesstransformer.cfg file and make the field public via it. In this file field names look like f_<numbers>. And I was unable to figure out, how to get those. It seems like it is connected to something called mappings (thing left after Minecraft decompile process). How can I get such a name for a class field?
  • Topics

×
×
  • Create New...

Important Information

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