Hello, I am busy on a Runescape mod.. But i cant find a tutorial for a Skill system (Different skills: Woodcutting, Fishing, Farming etc... Every skill has his own: level, total XP and unlocks Example: when my farming level is 4 i can only harvest and plant tomatoes, from harvesting 1 tomatoe i will get 5xp for Farming and i still need 10xp to be level 5 so when i harvest 2 tomatoes i will get 5xp X 2 so 10xp then I am level 5 so i can harvest and plant Onions. And you can use better tools on higher levels Example: I am level 5 when i get enough xp to get level 10 i can use a iron rake and when i am level 15 i can use a Golden rake. When i am level 10 i can not use a golden rake to harvest. When i am level 11 or higher i can still use an Iron Rake You also need a different amount of xp for each level Example: When i am level 10 I need 10xp to be level 11 and from level 11 i need 20xp to level 12 Can someone give me an Example code? Please help me I really need this!
Use IExtendedEntityProperties, and an event listener for the BlockHarvestEvent
I don't think you can make a new one, but if you did, you would need to use reflections to add a new dye variable to each dye array, such as EntitySheep.colorTable, and the couple in ItemDye.
for the unlocalized name thing, add a lang file to your mod. I'll help you once i can see whats wrong, but i have a clearer idea of whats wrong now.
The names worked without a lang file before. I'm not really sure how to use them because I never have before.
I can't get a picture right now because when I try to launch the game in eclipse and when I click into a world, it goes back to the title screen, kinda freezes, and my CPU jumps to like >90% :S
The names worked without a lang file before. I'm not really sure how to use them because I never have before.
I can't get a picture right now because when I try to launch the game in eclipse and when I click into a world, it goes back to the title screen, kinda freezes, and my CPU jumps to like >90% :S
How would I get a block to disable all mob spawning within a certain radius of it?
Also, how would I get a furnace block to detect if there is a specific entity (such as a pig) close by in order to smelt an item? Like within a ten square radius.
How would I get a block to disable all mob spawning within a certain radius of it?
Also, how would I get a furnace block to detect if there is a specific entity (such as a pig) close by in order to smelt an item? Like within a ten square radius.
first one i am not sure, maybe check if there's a mob and kill it?
second one, just use a tile entity should be able to check for mobs
Oh right >_> I forgot to check!!! I can't get on right now ;-;
I'm going to assume there were none because the game never crashed, I just kept frantically clicking exit so my laptop didn't blow up into a huge mess. :S
first one i am not sure, maybe check if there's a mob and kill it?
second one, just use a tile entity should be able to check for mobs
Checking for mobs and then killing them might work.. I'm looking for some sort of way to basically protect an area of a certain radius from mobs spawning to create safe towns, villages, etc. so killing the mobs might be a bit strange if they still appear, and also I would need to ensure that they do not drop anything upon death.
As for the second question, I guess to be more clear, I was wanting to know how to check for a specific mob.
Checking for mobs and then killing them might work.. I'm looking for some sort of way to basically protect an area of a certain radius from mobs spawning to create safe towns, villages, etc. so killing the mobs might be a bit strange if they still appear, and also I would need to ensure that they do not drop anything upon death.
As for the second question, I guess to be more clear, I was wanting to know how to check for a specific mob.
for the first, i think you can clear the drops
for the second, you can just do if(entity instanceof EntityPig){
//do something
}
Checking for mobs and then killing them might work.. I'm looking for some sort of way to basically protect an area of a certain radius from mobs spawning to create safe towns, villages, etc. so killing the mobs might be a bit strange if they still appear, and also I would need to ensure that they do not drop anything upon death.
As for the second question, I guess to be more clear, I was wanting to know how to check for a specific mob.
for the first one, check for entities within a certiain aabb, then use
if(!e.worldObj.isRemote)
{
e.setDead();
}
on the entities you wanna kill. For the second one, do the same AABB thing, just dont kill them, return the entity.
World has a method, called getEntitiesWithinAABB && getEntitiesWithinAABBExcludingEntity, which is a list, List<Entity> and you can use the iterator in the list, if you need an example, look at TileEntityBeacon.
Oh right >_> I forgot to check!!! I can't get on right now ;-;
I'm going to assume there were none because the game never crashed, I just kept frantically clicking exit so my laptop didn't blow up into a huge mess. :S
sorry if i already asked you this (i honestly don't remember) can you show me your code again? in spoilers though, so it doesn't take up half the page. I had a problem, kinda like that, but it was with a model, where i put body.addChild in the wrong spot, so it was called every tick instead of once. you might have that kinda problem.
i'm confused too, i mean where do you have to put that eventlistener and what do you have to fill in as arguments. I'm really new to coding, i don't know much about coding stuff
sorry if i already asked you this (i honestly don't remember) can you show me your code again? in spoilers though, so it doesn't take up half the page. I had a problem, kinda like that, but it was with a model, where i put body.addChild in the wrong spot, so it was called every tick instead of once. you might have that kinda problem.
i hope i helped!
Here's my latest block that might have caused the problem. I used the block flawlessly for awhile without any problems, and I don't think it's related, because the CPU thingy happened when I created a new superflat world (would show the main menu when I click the world).
I took out the imports because they just take up space .-.
TileEntity:
public class TileEntityIndComposter extends TileEntity implements ISidedInventory{
// Initialize variables. Yayyyyy~~~~~
public static final int[] slots_top = new int[]{0, 1};
private ItemStack[] slots = new ItemStack[2];
private String localizedName;
public Random rand = new Random();
public int compostProgress;
public int maxCompostProgress = 200;
//////////////////////////////////////////////////////////// End Initialization o3o
//////////////////////////////////////////// Buncha random (necessary) functions
public String getInvName(){
return this.isInvNameLocalized() ? this.localizedName : "container.indComposter";
}
public boolean isInvNameLocalized() {
return this.localizedName != null && this.localizedName.length() > 0;
}
public void setGuiDisplayName(String displayName){
this.localizedName = displayName;
}
public int getSizeInventory(){
return 2;
}
public ItemStack getStackInSlot(int i) {
return this.slots[i];
}
public ItemStack decrStackSize(int i, int j) {
if(this.slots[i] != null){
ItemStack itemstack;
if(this.slots[i].stackSize <= j){
itemstack = this.slots[i];
this.slots[i] = null;
return itemstack;
}else{
itemstack = this.slots[i].splitStack(j);
if(this.slots[i].stackSize == 0){
this.slots[i] = null;
}
return itemstack;
}
}
return null;
}
public ItemStack getStackInSlotOnClosing(int i) {
if(this.slots[i] != null){
ItemStack itemstack = this.slots[i];
this.slots[i] = null;
return itemstack;
}
return null;
}
public void setInventorySlotContents(int i, ItemStack itemstack) {
this.slots[i] = itemstack;
if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){
itemstack.stackSize = this.getInventoryStackLimit();
}
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
public int[] getAccessibleSlotsFromSide(int var1) {
return slots_top;
}
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return isItemValidForSlot(i, itemstack);
}
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return i == 1;
}
/** Where the fun starts **/
public void readFromNBT(NBTTagCompound nbt){
super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("Items");
this.slots = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compound = (NBTTagCompound) list.tagAt(i);
byte b = compound.getByte("Slot");
if(b >= 0 && b < this.slots.length){
this.slots[b] = ItemStack.loadItemStackFromNBT(compound);
}
}
this.compostProgress = nbt.getShort("compostProgress");
if(nbt.hasKey("CustomName")){
this.localizedName = nbt.getString("CustomName");
}
}
public void writeToNBT(NBTTagCompound nbt){
super.writeToNBT(nbt);
nbt.setShort("compostProgress", (short)this.compostProgress);
NBTTagList list = new NBTTagList();
for(int i = 0; i < this.slots.length; i++){
if(this.slots[i] != null){
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Slot", (byte)i);
this.slots[i].writeToNBT(compound);
list.appendTag(compound);
}
}
nbt.setTag("Items", list);
if(this.isInvNameLocalized()){
nbt.setString("Custom Name", this.localizedName);
}
}
public void updateEntity(){ //Updates the entity (20 ticks -> 1 second)
if(!this.worldObj.isRemote){
if(this.canCompost()){
++this.compostProgress;
if(this.compostProgress >= this.maxCompostProgress){
this.compostProgress = 0;
this.compost();
}
}else{
this.compostProgress = 0;
}
}
}
public boolean isComposting(){ //True if composting
return this.compostProgress > 0;
}
public static ItemStack getCompostResults(ItemStack itemstack){ //Add more items for more "composting" options
if(itemstack == null){
return null;
}else{
if(itemstack.itemID == Item.rottenFlesh.itemID) return new ItemStack(Item.appleGold, 5);
if(itemstack.itemID == Block.leaves.blockID) return new ItemStack(Block.sapling, 1, itemstack.getItemDamage());
if(itemstack.itemID == Block.sapling.blockID) return new ItemStack(Block.dirt, 1);
if(itemstack.itemID == Item.glowstone.itemID) return new ItemStack(Item.goldNugget, 2);
if(itemstack.itemID == Item.netherStalkSeeds.itemID) return new ItemStack(Block.slowSand, 1);
if(itemstack.itemID == Block.slowSand.blockID) return new ItemStack(Item.netherQuartz, 1);
if(itemstack.itemID == Block.gravel.blockID) return new ItemStack(Item.flint, 1);
if(itemstack.itemID == Item.bucketMilk.itemID) return new ItemStack(Item.slimeBall, 2);
return null;
}
}
public boolean canCompost(){ //True if the tile entity is able to compost the input
if(this.slots[0] == null){
return false;
}else{
ItemStack resultItem = getCompostResults(this.slots[0]);
if(resultItem == null) return false;
if(this.slots[1] == null) return true;
if(!this.slots[1].isItemEqual(resultItem)) return false;
int result = slots[1].stackSize + resultItem.stackSize;
return (result <= getInventoryStackLimit() && result <= resultItem.getMaxStackSize());
}
}
public void compost(){ //Compost the item in input if compostable
if(canCompost()){
ItemStack inputItem = this.slots[0];
ItemStack resultItem = getCompostResults(this.slots[0]);
if(this.slots[1] == null){
this.slots[1] = resultItem.copy();
}else if(this.slots[1].isItemEqual(resultItem)){
this.slots[1].stackSize += resultItem.stackSize;
}
if(inputItem.itemID == Block.sapling.blockID){
this.slots[0].stackSize -= 4;
}else{
this.slots[0].stackSize -= resultItem.stackSize;
}
if(this.slots[0].stackSize <= 0){
this.slots[0] = this.slots[0].getItem().getContainerItemStack(this.slots[0]);
}
}
}
public static boolean isItemFuel(ItemStack itemstack){ //True if slot == compostable
return getCompostResults(itemstack) != null;
}
public boolean isItemValidForSlot(int i, ItemStack itemstack) { //True if... it's valid
return i == 1 ? false : isItemFuel(itemstack);
}
public int getcompostProgressRemainingScaled(int i){ //For Gui thingy.
return this.compostProgress * i / this.maxCompostProgress;
}
/** Where the fun ends :/ **/
///////////////////////// Can't get rid of these .-.
public void openChest() {
}
public void closeChest() {
}
}
Gui:
public class GuiIndComposter extends GuiContainer{
public static ResourceLocation texture = new ResourceLocation("omnirandom", "textures/blocks/indcGui.png");
public TileEntityIndComposter indComposter;
public GuiIndComposter(InventoryPlayer inventoryPlayer, TileEntityIndComposter entity) {
super(new ContainerIndComposter(inventoryPlayer, entity));
this.indComposter = entity;
int xSize = 176;
int ySize = 166;
}
public void drawGuiContainerForegroundLayer(int par1, int par2)
{
String name = this.indComposter.isInvNameLocalized() ? this.indComposter.getInvName() : I18n.getString(this.indComposter.getInvName());
this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, 4210752);
this.fontRenderer.drawString(I18n.getString("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
public void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(this.indComposter.isComposting())
{
int k = this.indComposter.getcompostProgressRemainingScaled(33);
this.drawTexturedModalRect(guiLeft + 71, guiTop + 16, 176, 0, k, 34);
}else{
this.drawTexturedModalRect(guiLeft + 71, guiTop + 16, 176, 0, 0, 34);
}
}
}
Got a question I couldn't find the answer for, and figured it was the best place to ask:
Why are there no mods for 1.7.9, and all of them are still 1.7.2 ?
I've read a few things about forge not being updated to 1.7.9, but isn't it possible to have mods working without it ?
-It will generate as normal ore
Example: CopperOre, when you mine the ore you will get a copperore item (Not the Block!)
And the block will not be destroyed but it will change to a empty ore block and the pickaxe will stop mining (you have to press the left click agin for mining) and the ore will be full when 100sec are over
Code please?
Make a block a tile entity and set a timer for it! And for the block breaking, I believe there's a method for it, check the block class!
Got a question I couldn't find the answer for, and figured it was the best place to ask:
Why are there no mods for 1.7.9, and all of them are still 1.7.2 ?
I've read a few things about forge not being updated to 1.7.9, but isn't it possible to have mods working without it ?
You can but you will have to edit the minecraft classes which will cause incompatibility with almost every mod. Someone tell me if I am wrong please xD
It needs to be almost the same is diamond or emerald
There is a DiamondBlock and a DiamondItem
-> There is a CopperOreBlock and a CopperOreItem
And the block will not be destroyed but it will change to a empty ore block and the pickaxe will stop mining (you have to press the left click agin for mining) and the ore will be full when 100sec are over
Code please
Giving you code won't help you to learn so here's the steps for it.
For the changing the block when a block is broken, there's a method called onBlockDestroyed or something similar, then just replace the block with a empty ore block with the same location and drop a copper ore item.
For the empty ore block, make it extend tile entity and make a cool down timer for it, if the timer reaches 0, make it set the block back to a full ore block.
Basically, setup your config file in your FMLPreInitialization Event:
// The true/false that you'll be using to check if you're doing something
public static boolean useMahCrafting;
@EventHandler
public void preInit(FMLPreInitializationEvent event){
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
// Where all your config goes //
useMahCrafting = config.get(config.CATEGORY_MYCATEGORY, "useCrafting", false).getBoolean(false);
// config.Category = the category it's under
// "useCrafting" = name of the thing. It'll show up as "B: useCrafting = false"
// false = the default it'll use if there's no value yet
// getBoolean(false) = I think this is also the default value. Just keep it the same as the default in get()
//
config.save();
}
@EventHandler
public void init(FMLInitializationEvent event){
if(useMahCrafting){
//Crafting stuff if it's true in the config
}
}
Use IExtendedEntityProperties, and an event listener for the BlockHarvestEvent
I don't think you can make a new one, but if you did, you would need to use reflections to add a new dye variable to each dye array, such as EntitySheep.colorTable, and the couple in ItemDye.
forgive me if im wrong, but i think you're using the wrong parameters in setRotationAngles.
97
The names worked without a lang file before. I'm not really sure how to use them because I never have before.
I can't get a picture right now because when I try to launch the game in eclipse and when I click into a world, it goes back to the title screen, kinda freezes, and my CPU jumps to like >90% :S
:3
any crash reports or errors?
"There's a difference between things that end and things that can't continue."
disable Minecraft's crafting recipes or your own mod's crafting recipes?
I have two questions:
How would I get a block to disable all mob spawning within a certain radius of it?
Also, how would I get a furnace block to detect if there is a specific entity (such as a pig) close by in order to smelt an item? Like within a ten square radius.
first one i am not sure, maybe check if there's a mob and kill it?
second one, just use a tile entity should be able to check for mobs
Oh right >_> I forgot to check!!! I can't get on right now ;-;
I'm going to assume there were none because the game never crashed, I just kept frantically clicking exit so my laptop didn't blow up into a huge mess. :S
:3
Checking for mobs and then killing them might work.. I'm looking for some sort of way to basically protect an area of a certain radius from mobs spawning to create safe towns, villages, etc. so killing the mobs might be a bit strange if they still appear, and also I would need to ensure that they do not drop anything upon death.
As for the second question, I guess to be more clear, I was wanting to know how to check for a specific mob.
for the first, i think you can clear the drops
for the second, you can just do if(entity instanceof EntityPig){
//do something
}
My own mod's crafting recipes
"There's a difference between things that end and things that can't continue."
have a boolean value in your config file, which will decide whether or not to register your crafting
you dont need code for that... what you would do is override onItemUse in the item class, then do
for the first one, check for entities within a certiain aabb, then use
on the entities you wanna kill. For the second one, do the same AABB thing, just dont kill them, return the entity.
World has a method, called getEntitiesWithinAABB && getEntitiesWithinAABBExcludingEntity, which is a list, List<Entity> and you can use the iterator in the list, if you need an example, look at TileEntityBeacon.
sorry if i already asked you this (i honestly don't remember) can you show me your code again? in spoilers though, so it doesn't take up half the page. I had a problem, kinda like that, but it was with a model, where i put body.addChild in the wrong spot, so it was called every tick instead of once. you might have that kinda problem.
i hope i helped!
97
This might help!
http://www.minecraftforum.net/topic/1952901-172164-eventhandler-and-iextendedentityproperties/
Here's my latest block that might have caused the problem. I used the block flawlessly for awhile without any problems, and I don't think it's related, because the CPU thingy happened when I created a new superflat world (would show the main menu when I click the world).
I took out the imports because they just take up space .-.
TileEntity:
Gui:
Container:
:3
I don't exactly know how to do that, so can I have an example?
(my first time working with config files...)
"There's a difference between things that end and things that can't continue."
Why are there no mods for 1.7.9, and all of them are still 1.7.2 ?
I've read a few things about forge not being updated to 1.7.9, but isn't it possible to have mods working without it ?
Make a block a tile entity and set a timer for it! And for the block breaking, I believe there's a method for it, check the block class!
You can but you will have to edit the minecraft classes which will cause incompatibility with almost every mod. Someone tell me if I am wrong please xD
Giving you code won't help you to learn so here's the steps for it.
For the changing the block when a block is broken, there's a method called onBlockDestroyed or something similar, then just replace the block with a empty ore block with the same location and drop a copper ore item.
For the empty ore block, make it extend tile entity and make a cool down timer for it, if the timer reaches 0, make it set the block back to a full ore block.
anyone else to help me?
"There's a difference between things that end and things that can't continue."
Google can help o3o
http://www.minecraftforge.net/wiki/Tutorials/Configuration_files
Basically, setup your config file in your FMLPreInitialization Event:
:3