Jump to content

Macintoshuser_2

Members
  • Posts

    23
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Location
    In front of my computer
  • Personal Text
    Developer for Mac's Utilities Remastered

Recent Profile Visitors

1207 profile views

Macintoshuser_2's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, I have just attempted a few times to create a new project using the new mdk for forge 1.13.2 and every single time, the ./gradlew eclipse works, but ./gradlew setupDecompWorkspace doesn't. It always comes up with an error saying that it's not found. here is the eroor with the stacktrace that I am receiving. How would I fix this? https://pastebin.com/rWa5CwyF
  2. Hello, I would like to have some of my colored glowstone blocks give off light that corresponds to its color. How would I go about doing this?
  3. Never mind about the previous reply. I forgot to register the TileEntity. *facepalm* Works fine now.
  4. Ok, I made the changes and the gui will now open. I am however still having trouble with the NBT. The Items in the slot will not save to NBT when I log out of the world and will not read it when I get back into the world. I am also still having the issue of Items not dropping when I break the block. I put the code on github that way it'd just make it a whole lot easier. BlockRFGenerator.java: https://github.com/Macintoshuser2/MacsUtilitiesRemastered/blob/master/src/main/java/com/macintoshuser2/macsutilities/blocks/BlockRFGenerator.java ContainerRFGenerator.java: https://github.com/Macintoshuser2/MacsUtilitiesRemastered/blob/master/src/main/java/com/macintoshuser2/macsutilities/container/ContainerRFGenerator.java TileEntityRFGenerator.java: https://github.com/Macintoshuser2/MacsUtilitiesRemastered/blob/master/src/main/java/com/macintoshuser2/macsutilities/tileentities/TileEntityRFGenerator.java GuiRFGenerator.java: https://github.com/Macintoshuser2/MacsUtilitiesRemastered/blob/master/src/main/java/com/macintoshuser2/macsutilities/client/gui/GuiRFGenerator.java
  5. I made the changes to the container and now I can't open the GUI and the block won't drop items upon being broken. ContainerRFGenerator.java: package com.macintoshuser2.macsutilities.container; import com.macintoshuser2.macsutilities.tileentities.TileEntityRFGenerator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerRFGenerator extends Container { private TileEntityRFGenerator rfGen; public ContainerRFGenerator(IInventory playerInventory, TileEntityRFGenerator rfGen) { this.rfGen = rfGen; this.addSlotToContainer(new SlotItemHandler((IItemHandler) rfGen, 0, 30, 35)); for(int y = 0; y < 3; ++y) { for(int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } for(int x = 0; x <9; ++x) { this.addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; //return this.rfGen.isUseableByPlayer(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = null; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if(slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if(fromSlot < 1) { if(!this.mergeItemStack(current, 1, this.inventorySlots.size(), true)) { return null; } } else { if(!this.mergeItemStack(current, 0, 1, false)) { return null; } } if(current.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } } return previous; } } TileEntityRFGenerator.java: package com.macintoshuser2.macsutilities.tileentities; import javax.annotation.Nullable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityRFGenerator extends TileEntity { private ItemStackHandler inventory = new ItemStackHandler(1); @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inventory.serializeNBT()); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inventory.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inventory : super.getCapability(capability, facing); } } BlockRFGenerator.java: package com.macintoshuser2.macsutilities.blocks; import java.util.List; import org.lwjgl.input.Keyboard; import com.macintoshuser2.macsutilities.MacsUtilities; import com.macintoshuser2.macsutilities.client.gui.MacGuiHandler; import com.macintoshuser2.macsutilities.tileentities.TileEntityRFGenerator; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; public class BlockRFGenerator extends BlockContainer { public BlockRFGenerator() { super(Material.IRON); this.setUnlocalizedName("rf_generator"); this.setRegistryName("rf_generator"); } @Override public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { TileEntityRFGenerator rfGen = new TileEntityRFGenerator(); IItemHandler itemHandler = rfGen.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); ItemStack stack = itemHandler.getStackInSlot(0); if(stack != null) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack); world.spawnEntityInWorld(item); } super.breakBlock(world, pos, blockstate); } @Override public boolean isFullBlock(IBlockState state) { return true; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) { tooltip.add(TextFormatting.BOLD + "<HOLD LEFT SHIFT FOR MORE INFO>"); if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { tooltip.remove(1); tooltip.add(TextFormatting.RED + "Redstone Dust = 50 RF/t"); tooltip.add(TextFormatting.RED + "Redstone Block = 450 RF/t"); } } @Override public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { return entity instanceof EntityWither || entity instanceof EntityDragon ? false : true; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityRFGenerator(); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { playerIn.openGui(MacsUtilities.instanceOfMacUtil, MacGuiHandler.RF_GENERATOR_IDENTIFIER, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } }
  6. How would I go about changing my container accordingly upon making that change?
  7. Hello, I am having a bit of trouble with the Tile Entity for my RF Generator for my mod, Mac's Utilities Remastered. The problem that I am having is that when I put a stack of Items into a slot in the GUI, close the GUI, exit the world, and then rejoin the world, the Items that were in the slot were not saved to NBT. How do I fix this? TileEntityRFGenerator.java: package com.macintoshuser2.macsutilities.tileentities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; public class TileEntityRFGenerator extends TileEntity implements IInventory { private ItemStack[] inventory; private String customName; public TileEntityRFGenerator() { this.inventory = new ItemStack[this.getSizeInventory()]; } public void setCustomName(String customName) { this.customName = customName; } public String getCustomName() { return customName; } @Override public String getName() { return this.hasCustomName() ? this.customName : "container.rfGenerator"; } @Override public boolean hasCustomName() { return this.customName != null && !this.customName.equals(""); } @Override public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName()); } @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int index) { if(index < 0 || index >= this.getSizeInventory()) { return null; } return this.inventory[index]; } @Override public ItemStack decrStackSize(int index, int count) { if(this.getStackInSlot(index) != null) { itemstack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); this.markDirty(); return itemstack; } else { itemstack = this.getStackInSlot(index).splitStack(count); if(this.getTackInSlot(index).stackSize <= 0) { this.setInventorySlotContents(index, null); } else { this.setInventorySlotContents(index, this.getStackInSlot(index)); } this.markDirty(); return itemstack; } } else { return null; } @Override public void setInventorySlotContents(int index, ItemStack stack) { if(index < 0 || index >= this.getSizeInventory()) { return; } if(stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } if(stack != null && stack.stackSize == 0) { stack = null; } this.inventory[index] = stack; this.markDirty(); } @Override public ItemStack removeStackFromSlot(int index) { ItemStack stack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64 } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return stack.getItem() == Items.REDSTONE || stack.getItem() == Item.getItemFromBlock(Blocks.REDSTONE_BLOCK) ? true : false; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { for(int i = 0; i < this.getSizeInventory(); i++) { this.setInventorySlotContents(i, null); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); NBTTagList list = new NBTTagList(); for(int i = 0; i < this.getSizeInventory(); ++i) { if(this.getStackInSlot(i) != null) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); this.getStackInSlot(i).writeToNBT(stackTag); list.appendTag(stackTag); } } nbt.setTag("Items", list); if(this.hasCustomName()) { nbt.setString("CustomName", this.getCustomName()); } return nbt; } @Override public void redFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); for(int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); } if(nbt.hasKey("CustomName", ) { this.setCustomName(nbt.getString("CustomName")); } } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } } How do I fix it?
  8. To my knowledge, Minecraft Forge for 1.11 does not currently support registering custom entities as of yet. (I, however, could be wrong.)
  9. I can't run the gradlew build command in the command line. this is all in eclipse. Would it help if I provided a list of how I set up the project? My setup process was 1. Download src from forge site 2. unzip and place files in a folder. 3. run gradlew setupDecompWorkspace eclipse 4. open eclipse and right click project > Properties > Java Build Path > Libraries > Add External Jar > Select Jar > Open > Apply
  10. Now that I have it formatted as such, @Mod(modid="macutiladdon", version="0.1", name="Tree Generation Addon", dependencies="required-after:macid@[2.1.0]") Is there anything else I need to do? Because I tried running it, with the correct jar in the mods folder and it doesn't work. it just come up with a screen that says, "Forge Mod Loader has found a problem with you minecraft installation You have mod sources that are duplicate within your system Mod Id : File name macid : [1.7.10]Mac's Utilities v2.1.0..jar macid : [1.7.10]Mac's utilities v2.1.0..jar" The only other place I have the jar is as a referenced library in eclipse.
  11. Hi, I am trying to develop an addon for a mod but I do not quite understand the dependencies part of the @Mod Annotation. Can someone clarify this for me? This is my @Mod Annotation as of now: @Mod(modid="addon", version="0.1", name="Tree Generation Addon", dependencies="required-after:[1.7.10]Mac's Utilities v2.0.1.jar") What is the exact format for this?
  12. To my knowledge since 1.7 Forge has not been bundled with documentation. I learn how to do certain things by looking at open source mods on GitHub as well as look at the vanilla classes
  13. The lang file is located in src/main/resources/assets/<my modid>/lang The Block Textures are located in src/main/resources/assets/<my modid>/textures/blocks The Item Textures are located in src/main/resources/assets/<my modid>/textures/items
  14. Hi, upon reinstalling Windows 7 Professional 64-bit on my Main Machine, where I develop my mod, Mac's Utilities, I have run into an issue. When ever I load up the mod inside of my development environment (eclipse) and run the game from there, it doesn't find the textures nor the Language file. How can I fix this?
×
×
  • Create New...

Important Information

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