Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

spooglecraft

Members
  • Joined

  • Last visited

  1. Thank you, @diesieben07 ! I forgot that you have to add "break;" to "switch". And thanks for the article.
  2. I'm trying to replace a block when it's right-clicked with a certain item and arranged in a certain structure. Multiple structures are possible, resulting in different block replacements. I'm doing this by setting a variable depending on the structure built around the block. The variable is then passed to the "assemble" method, which contains a switch for the variable. The variable is a string called "setup". I also print "setup" to the log, which always returns the correct result for the structure. However, the block always changes into the block for the structure "Generator". /** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { SCExtendedPlayer props = SCExtendedPlayer.get(p_149727_5_); String setup = "Machine";//The default setup value //Charger Setup - The comparation blocks if ((p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_, p_149727_4_) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_, p_149727_4_) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_, p_149727_4_ + 1) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_, p_149727_4_ - 1) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock)){ setup = "Charger"; } //Generator Setup if ((p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_ + 1) == Blocks.air) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_ - 1) == Blocks.air) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_) == SCBlocks.VintryteGenerator) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock)){ setup = "Generator"; } //Generator Setup if ((p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_) == Blocks.air) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_ + 1) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_ - 1) == SCBlocks.VintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_ + 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_) == Blocks.air) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_) == SCBlocks.VintryteGenerator) && (p_149727_1_.getBlock(p_149727_2_ - 1, p_149727_3_ - 1, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock) && (p_149727_1_.getBlock(p_149727_2_ + 1, p_149727_3_ - 1, p_149727_4_ - 1) == SCBlocks.CompositeVintryteBlock)){ setup = "Generator"; } //Coil Setup if ((p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 1, p_149727_4_) == SCBlocks.VintryteCoil) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 2, p_149727_4_) == SCBlocks.VintryteCoil) && (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ - 3, p_149727_4_) == SCBlocks.VintryteCoil)){ setup = "Coil"; } if (setup.equals("Machine")){ p_149727_1_.setBlock(p_149727_2_, p_149727_3_, p_149727_4_, SCBlocks.VintryteMachine); } ModMainClass.log.info(setup);//Logging "setup" if (p_149727_5_.inventory.getCurrentItem() != null)//Checking for the correct item, after checking if the player is holding an item { Item item = p_149727_5_.inventory.getCurrentItem().getItem(); if(item == SCItems.VintryteControllerT1){ if(((ItemVintryteControllerT1) item).mode == "Assemble")//Checking the item mode { assemble(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, setup);//Calling "assemble", passing the world, the coordinates, the player and the setup } } if(item == SCItems.VintryteControllerT2){ if(((ItemVintryteControllerT2) item).mode == "Assemble") { assemble(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, setup); } } if(item == SCItems.VintryteControllerT3){ if(((ItemVintryteControllerT3) item).mode == "Assemble") { assemble(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, setup); } } } if (p_149727_1_.isRemote) { return true; } else { return false; } } void assemble(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, String setup){//The "assemble" method switch(setup) { case "Machine": p_149727_1_.setBlock(p_149727_2_, p_149727_3_, p_149727_4_, SCBlocks.VintryteMachine); case "Charger": p_149727_1_.setBlock(p_149727_2_, p_149727_3_, p_149727_4_, SCBlocks.VintryteCharger); p_149727_1_.playSoundAtEntity(p_149727_5_, "sctechmod:assemble", 1.0F, 1.0F); case "Coil": p_149727_1_.setBlock(p_149727_2_, p_149727_3_, p_149727_4_, SCBlocks.VintryteCoilCore); p_149727_1_.playSoundAtEntity(p_149727_5_, "sctechmod:assemble", 1.0F, 1.0F); case "Generator": p_149727_1_.setBlock(p_149727_2_, p_149727_3_, p_149727_4_, SCBlocks.VintryteGeneratorCore);//What always happens, no matter the setup p_149727_1_.playSoundAtEntity(p_149727_5_, "sctechmod:assemble", 1.0F, 1.0F); default: } }

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.