FANDOM


This Article is up to date with Custom Stuff 2 CS2

This page uses scripts to turn a regular custom weapon into something that allows mobs to drop custom items.

First, you will need a custom weapon to convert. If you do not already have one, please make one with the help of the normal items page. Make sure you set the damage attribute high enough to be worth killing mobs with.

After you finish making a custom weapon, add the following line of code to the end of your weapon.

onHitEntity = "mod.loadScript('mobKilled.js');";

scripts/mobKilled.js

This script, however, is currently only set up for dropping a bowl(281) with a 25% drop rate. You will need to edit the individual drops manually for this script to be of much use.

Fortunately, not much is required to change individual mob drops. For those who have not looked at the full script yet, the below block represents one mob (Creeper) that can be customized.

case "Creeper":
	if(Math.floor(Math.random()*100) < 25 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
	}
	break;

The if conditions generate a number between 0 and 99 and compare it to 25. This causes the drop rate to be exactly 25% per check. The living.getHealth function checks to see if the mob is now dead. If both of these conditions are true, the code inside the { } will activate.

Inside the { } is the living.dropItem function used to make a mob drop a custom item. The first number is the item id for a bowl(281). Next is the quantity dropped. Finally, the last number(0) is the damage dropped, useful if you want a damaged block or a damaged tool to drop [ex. near-broken stone pickaxe].

As it is set up now, when an item is dropped, it will always drop an exact amount. If you want to have a varied amount drop (1-5 dropped) you can use the math.random function again like so.

case "Creeper":
	if(Math.floor(Math.random()*100) < 75 && living.getHealth() <= 0)
	{
		living.dropItem(281, Math.floor(Math.random()*5+1), 0);
	}
	break;

This version will cause 1 to 5 bowls to drop when the custom items are dropped at all. You can also make multiple different items drop by adding extra living.dropItem functions.

case "Creeper":
	if(Math.floor(Math.random()*100) < 25 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
		living.dropItem(81, 1, 0);
	}
	break;

Now creepers will not only drop a bowl(281), but they will also drop a cactus(81). However, this setup will cause the items to always drop at the same time. If you want the two drops to be independant of each other but can still drop together by chance, you can add an additional if statement to make it look like this.

case "Creeper":
	if(Math.floor(Math.random()*100) < 15 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
	}
	if(Math.floor(Math.random()*100) < 30 && living.getHealth() <= 0)
	{
		living.dropItem(81, 1, 0);
	}
	break;

Notice that I have also changed the drop rates for the items. In this example, bowls will drop 15% of the time, and cactus will drop 30% of the time.

Other functions can also be used for some interesting effects if you desire. To know what functions are supported, check under the onHitEntity attribute once the help file is updated with it (likely 0.9.4 help file). Exactly what you can do will not be covered here though since this is the "Weapon of Drops" and therefore is focused on drops.

The effects of this example does not, unfortunately, carry over to any vanilla items or items from other mods. If you want though, you can remove the existing recipes for those items and replace the recipes using your own custom items. Refer to the recipes page for more information on how to do this.


CS1
Older Examples and Information for Custom Stuff 1.

by Flamarow

This page uses scripts to turn a regular custom weapon into something that allows mobs to drop custom items. This page might eventually be converted into a project page in the future, but for now it will simply be an example. Feel free to add your name to the top if you contributed or just remove the contributor list completely if you consider it unnecessary.

First, you will need a custom weapon to convert. If you do not already have one, please make one with the help of the normal items page. Make sure you set the damage attribute high enough to be worth killing mobs with.

After you finish making a custom weapon, add the following line of code to the end of your weapon.

hitmob = "customstuff.loadScript('mobkilled.script');";

This will call the script file called "mobkilled.script" to execute the main code. The contents of that script can be found below. Because of the length of the script, you will need to hit "show" to see the contents of the script.

Be aware that the "" + before living.getType is only to ensure that the currentmob is considered a string. If getType ever outputs a string, the changes will be useless, but they will not interfere with the code.

This script, however, is currently only set up for dropping a bowl(281) with a 25% drop rate. You will need to edit the individual drops manually for this script to be of much use.

Fortunately, not much is required to change individual mob drops. For those who have not looked at the full script yet, the below block represents one mob (Creeper) that can be customized.

case "Creeper":
	if(Math.floor(Math.random()*100) < 25 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
	}
	break;

The if conditions generate a number between 0 and 99 and compare it to 25. This causes the drop rate to be exactly 25% per check. The living.getHealth function checks to see if the mob is now dead. If both of these conditions are true, the code inside the { } will activate.

Inside the { } is the living.dropItem function used to make a mob drop a custom item. The first number is the item id for a bowl(281). Next is the quantity dropped. Finally, the last number(0) is the damage dropped, useful if you want a damaged block or a damaged tool to drop [ex. near-broken stone pickaxe].

As it is set up now, when an item is dropped, it will always drop an exact amount. If you want to have a varied amount drop (1-5 dropped) you can use the math.random function again like so.

case "Creeper":
	if(Math.floor(Math.random()*100) < 75 && living.getHealth() <= 0)
	{
		living.dropItem(281, Math.floor(Math.random()*5+1), 0);
	}
	break;

This version will cause 1 to 5 bowls to drop when the custom items are dropped at all. You can also make multiple different items drop by adding extra living.dropItem functions.

case "Creeper":
	if(Math.floor(Math.random()*100) < 25 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
		living.dropItem(81, 1, 0);
	}
	break;

Now creepers will not only drop a bowl(281), but they will also drop a cactus(81). However, this setup will cause the items to always drop at the same time. If you want the two drops to be independant of each other but can still drop together by chance, you can add an additional if statement to make it look like this.

case "Creeper":
	if(Math.floor(Math.random()*100) < 15 && living.getHealth() <= 0)
	{
		living.dropItem(281, 1, 0);
	}
	if(Math.floor(Math.random()*100) < 30 && living.getHealth() <= 0)
	{
		living.dropItem(81, 1, 0);
	}
	break;

Notice that I have also changed the drop rates for the items. In this example, bowls will drop 15% of the time, and cactus will drop 30% of the time.

Other functions can also be used for some interesting effects if you desire. This is because the hitmob event can accept world functions, player functions and living functions. These will not be covered here though since this is the "Weapon of Drops" and therefore is focused on drops.

The effects of this example does not, unfortunately, carry over to any vanilla items. If you want though, you can remove the existing recipes for vanilla items and replace the recipes using your own custom items. Refer to the recipes page for more information on how to do this.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.