Best Unobtainium_ruby code snippet using Unobtainium.destroy
Constructable.java
Source:Constructable.java
...8 ConstructMenu getConstructMenu();9 default boolean isConstructing(){10 return getConstructMenu().getConstructTarget() != null;11 }12 default void construct(int optionIndex, Vector2 pos, boolean destroySelf){13 ConstructMenuItem constructTarget = getConstructMenu().getConstructMenuItem(optionIndex);14 if (constructTarget != null) {15 PlayerInfo playerInfo = GameController.getMainPlayer().getInfo();16 if(playerInfo.changeMetalAmount(constructTarget.getMetalCost()) &&17 playerInfo.changeUnobtainiumAmount(constructTarget.getUnobtainiumCost())){18 getConstructMenu().setConstructTarget(constructTarget);19 ((Sprite)this).setTask((task, delta) ->20 getConstructMenu().increaseProgress((double) delta/constructTarget.getConstructTime()),21 constructTarget.getConstructTime());22 ((Sprite)this).addTask((task, coroutineDelta) -> {23 try {24 Sprite newSprite = constructTarget.getInstance();25 newSprite.setPos(pos);26 SpritesController.addSprite(newSprite);27 } catch (IllegalAccessException | InstantiationException e) {28 e.printStackTrace();29 }30 getConstructMenu().setConstructTarget(null);31 getConstructMenu().setProgress(0);32 if(destroySelf) ((Sprite)this).destroySelf();33 task.stop();34 });35 }36 } else {37 System.out.println("ConstructError: construct menu option index out of bound!!!");38 }39 }40}...
UnobtainiumPillarItem.java
Source:UnobtainiumPillarItem.java
1package com.ranidgames.defmod.item;2import net.minecraftforge.registries.ObjectHolder;3import net.minecraft.item.Rarity;4import net.minecraft.item.ItemStack;5import net.minecraft.item.Item;6import net.minecraft.block.BlockState;7import com.ranidgames.defmod.itemgroup.DCMOresItemGroup;8import com.ranidgames.defmod.DefinitiveContentModModElements;9@DefinitiveContentModModElements.ModElement.Tag10public class UnobtainiumPillarItem extends DefinitiveContentModModElements.ModElement {11 @ObjectHolder("definitive_content_mod:unobtainium_pillar")12 public static final Item block = null;13 public UnobtainiumPillarItem(DefinitiveContentModModElements instance) {14 super(instance, 294);15 }16 @Override17 public void initElements() {18 elements.items.add(() -> new ItemCustom());19 }20 public static class ItemCustom extends Item {21 public ItemCustom() {22 super(new Item.Properties().group(DCMOresItemGroup.tab).maxStackSize(64).rarity(Rarity.UNCOMMON));23 setRegistryName("unobtainium_pillar");24 }25 @Override26 public int getItemEnchantability() {27 return 0;28 }29 @Override30 public int getUseDuration(ItemStack itemstack) {31 return 0;32 }33 @Override34 public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {35 return 1F;36 }37 }38}...
TrueUnobtainiumItem.java
Source:TrueUnobtainiumItem.java
1package com.ranidgames.defmod.item;2import net.minecraftforge.registries.ObjectHolder;3import net.minecraft.item.Rarity;4import net.minecraft.item.ItemStack;5import net.minecraft.item.Item;6import net.minecraft.block.BlockState;7import com.ranidgames.defmod.itemgroup.DCMOresItemGroup;8import com.ranidgames.defmod.DefinitiveContentModModElements;9@DefinitiveContentModModElements.ModElement.Tag10public class TrueUnobtainiumItem extends DefinitiveContentModModElements.ModElement {11 @ObjectHolder("definitive_content_mod:true_unobtainium")12 public static final Item block = null;13 public TrueUnobtainiumItem(DefinitiveContentModModElements instance) {14 super(instance, 295);15 }16 @Override17 public void initElements() {18 elements.items.add(() -> new ItemCustom());19 }20 public static class ItemCustom extends Item {21 public ItemCustom() {22 super(new Item.Properties().group(DCMOresItemGroup.tab).maxStackSize(64).rarity(Rarity.RARE));23 setRegistryName("true_unobtainium");24 }25 @Override26 public int getItemEnchantability() {27 return 0;28 }29 @Override30 public int getUseDuration(ItemStack itemstack) {31 return 0;32 }33 @Override34 public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {35 return 1F;36 }37 }38}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!