Blue_Atlas
Members-
Posts
132 -
Joined
-
Last visited
Everything posted by Blue_Atlas
-
I think I'm going to try putting a statement like this at the beginning of my update function If(detect blocks, making sure all are there with && statements) { this.burnTime = 5; } Would this.work and which function do I use to detect the blocks?(an example of the check would be nice) I do know how to do positioning already
-
How do I make a furnace like block run by having a set of blocks around it instead of using fuel? here is my current code for my tileentity package com.atlas.thelostportal.objects.blocks.tileentity; import com.atlas.thelostportal.objects.blocks.BlockNonEnergyForge; import com.atlas.thelostportal.objects.blocks.recipes.NonEnergyForgeRecipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityNonEnergyForge extends TileEntity implements ITickable { private ItemStackHandler handler = new ItemStackHandler(4); private String customName; private ItemStack smelting = ItemStack.EMPTY; private int burnTime; private int currentBurnTime; private int cookTime; private int totalCookTime = 200; @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; else return false; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) this.handler; return super.getCapability(capability, facing); } public boolean hasCustomName() { return this.customName != null && !this.customName.isEmpty(); } public void setCustomName(String customName) { this.customName = customName; } @Override public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.customName) : new TextComponentTranslation("container.sintering_furnace"); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.handler.deserializeNBT(compound.getCompoundTag("Inventory")); this.burnTime = compound.getInteger("BurnTime"); this.cookTime = compound.getInteger("CookTime"); this.totalCookTime = compound.getInteger("CookTimeTotal"); if(compound.hasKey("CustomName", 8)) this.setCustomName(compound.getString("CustomName")); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("BurnTime", (short)this.burnTime); compound.setInteger("CookTime", (short)this.cookTime); compound.setInteger("CookTimeTotal", (short)this.totalCookTime); compound.setTag("Inventory", this.handler.serializeNBT()); if(this.hasCustomName()) compound.setString("CustomName", this.customName); return compound; } public boolean isBurning() { return this.burnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(TileEntityNonEnergyForge te) { return te.getField(0) > 0; } public void update() { if(this.isBurning()) { --this.burnTime; BlockNonEnergyForge.setState(true, world, pos); } ItemStack[] inputs = new ItemStack[] {handler.getStackInSlot(0), handler.getStackInSlot(1)}; ItemStack fuel = this.handler.getStackInSlot(2); if(this.isBurning() || !fuel.isEmpty() && !this.handler.getStackInSlot(0).isEmpty() || this.handler.getStackInSlot(1).isEmpty()) { if(!this.isBurning() && this.canSmelt()) { if(this.isBurning() && !fuel.isEmpty()) { Item item = fuel.getItem(); fuel.shrink(1); if(fuel.isEmpty()) { ItemStack item1 = item.getContainerItem(fuel); this.handler.setStackInSlot(2, item1); } } } } if(this.isBurning() && this.canSmelt() && cookTime > 0) { cookTime++; if(cookTime == totalCookTime) { if(handler.getStackInSlot(3).getCount() > 0) { handler.getStackInSlot(3).grow(1); } else { handler.insertItem(3, smelting, false); } smelting = ItemStack.EMPTY; cookTime = 0; return; } } else { if(this.canSmelt() && this.isBurning()) { ItemStack output = NonEnergyForgeRecipes.getInstance().getNonEnergyForgeResult(inputs[0], inputs[1]); if(!output.isEmpty()) { smelting = output; cookTime++; inputs[0].shrink(1); inputs[1].shrink(1); handler.setStackInSlot(0, inputs[0]); handler.setStackInSlot(1, inputs[1]); } } } } private boolean canSmelt() { if(((ItemStack)this.handler.getStackInSlot(0)).isEmpty() || ((ItemStack)this.handler.getStackInSlot(1)).isEmpty()) return false; else { ItemStack result = NonEnergyForgeRecipes.getInstance().getNonEnergyForgeResult((ItemStack)this.handler.getStackInSlot(0), (ItemStack)this.handler.getStackInSlot(1)); if(result.isEmpty()) return false; else { ItemStack output = (ItemStack)this.handler.getStackInSlot(3); if(output.isEmpty()) return true; if(!output.isItemEqual(result)) return false; int res = output.getCount() + result.getCount(); return res <= 64 && res <= output.getMaxStackSize(); } } } public boolean isUsableByPlayer(EntityPlayer player) { return this.world.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } public int getField(int id) { switch(id) { case 0: return this.burnTime; case 1: return this.currentBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch(id) { case 0: this.burnTime = value; break; case 1: this.currentBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; } } }
-
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
alright, thanks -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
so I just have to use ./gradlew instead of gradlew if I'm setting up on mac? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
that command does what? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
i have not transferred my project yet -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
I'm on mac, and I am currently not using github at all for setup -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
I have it pointed to where I have extracted the files from the mdk download -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
when I run gradlew setupDecompWorkspace it tells me -bash: gradlew: command not found -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
Just tried setting it up on laptop and it isn't working, do I have to do a different process to setup on a macbook than I have to on windows? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
got it, thanks -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
would it work if I just loaded my current directory onto a flash drive and then pointed eclipse to the workspace on my laptop? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
as far as I know I can access the terminal but it may be on some form of restrictions, so if I can get a working workspace without having to use the terminal it would be nice -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
does it matter why I might not have access to the command terminal? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
I don't have command terminal access as far as I know and getting the setup files on my laptop is tricky, so I'm trying not to use the terminal and only put files on through GitHub if possible. -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
I'm sorry but I am still confused. What steps of setup do I need to do on my laptop if I already have eclipse installed but don't have anything else there that I need before I can copy my directory over and have it run properly? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
alright, let me rephrase my question now that I know more, if I copy my whole directory via GitHub what do I need to do to set up a new one on a different computer without any part installed to begin with? -
can I mod without doing the setup process?
Blue_Atlas replied to Blue_Atlas's topic in Modder Support
is it possible to at least skip the command terminal in 1.12.2? -
I have my mod I'm working on but I'm going traveling and want to keep working on it. However I do not want to do the setup process on my laptop, is there something I can do to just put the files on my laptop(through GitHub) and then be able to work on my mod while being able to test it? btw I'm on 1.12.2 and the main part I want to skip is installing forge and the command terminal
-
Here is the final code for anyone that wants to make an item like this: package com.atlas.nether_star_mod.objects.items; import javax.annotation.Nullable; import com.atlas.nether_star_mod.Main; import com.atlas.nether_star_mod.objects.init.ModItemsInit; import com.atlas.nether_star_mod.util.IHasModel; import com.google.common.collect.Multimap; import net.minecraft.block.BlockDispenser; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumAction; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemShieldOnlyOffHand extends Item { private final float attackDamage; public ItemShieldOnlyOffHand(String name, int durability, float attackDamage) { this.maxStackSize = 1; this.setMaxDamage(durability); this.attackDamage = 2.0F + attackDamage; this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } }); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(Main.netherstartab); ModItemsInit.ITEMS.add(this); } public float getAttackDamage() { return this.attackDamage; } public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { stack.damageItem(1, attacker); return true; } public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BLOCK; } public int getMaxItemUseDuration(ItemStack stack) { return 72000; } public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(handIn == EnumHand.OFF_HAND) { ItemStack itemstack = playerIn.getHeldItem(handIn); playerIn.setActiveHand(handIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } else { return new ActionResult<ItemStack>(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); } } public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double)this.attackDamage, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", 1, 0)); } return multimap; } } one note: it does not take damage when blocking
-
thanks i know this went a little off topic but it was good to know how to get rid of IHasModel!
-
but how do i do it for blocks then? that only works for the items.
-
Dude it is what I have for now, I don't have anything else for now. Anyways I got my item working like i wanted it to