-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewritten most parts of the HazardousItems module. Most important par…
…t: Name lookup is now default mc notation. Also included: An example config file with comments
- Loading branch information
Showing
9 changed files
with
896 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<HazardousItemList> | ||
<!-- for normal items (no fluid containers) use the default minecraft notation | ||
For *Item* elements, the "OnContactCheck" will check the block that is directly UNDER the player (The block | ||
he currently stands on --> | ||
<Item ItemName="minecraft:lava_bucket" ExactNameMatch="true" OnContactCheck="false" InventoryCheck="true"> | ||
<DamageEffect Source="inFire" Amount="0.5"/> | ||
<PotionEffect PotionID="19" TickDuration="100" Level="1"/> | ||
</Item> | ||
|
||
<!-- For fluid containers, use the /iih command to get the fluid's name. | ||
For *Fluid* elements, the "OnContactCheck" will check the block that is directly at the players coordinates. | ||
This is used to check if the player is currently swimming in this fluid --> | ||
<Fluid FluidName="lava" ExactNameMatch="true" OnContactCheck="false" InventoryCheck="true"> | ||
<DamageEffect Source="inFire" Amount="0.5"/> | ||
<PotionEffect PotionID="19" TickDuration="100" Level="1"/> | ||
</Fluid> | ||
|
||
<!-- Regeneration effect on contact with water. Since the fluid is now a block, it requires a different Name | ||
In most cases it is sufficient to just add the modID. Like water becomes minecraft:water, lava becomes minecraft:lava, and so on | ||
Be careful with "ExactNameMatch". It will safe you some lines here if you set it to true, but then *any* item containing *water* | ||
will match, obviously. So itemWaterTank, blockWaterSource, .. all those will match if ExactNameMatch is true --> | ||
<Fluid FluidName="minecraft:water" ExactNameMatch="true" OnContactCheck="true" InventoryCheck="false"> | ||
<PotionEffect PotionID="10" TickDuration="100" Level="1"/> | ||
</Fluid> | ||
</HazardousItemList> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.dreammaster.auxiliary; | ||
|
||
import com.dreammaster.modhazardousitems.HazardousItems.HazardousItem; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.Fluid; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.IFluidContainerItem; | ||
import cpw.mods.fml.common.registry.GameRegistry; | ||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; | ||
|
||
public class ItemHelper | ||
{ | ||
/** Try to find the fluid that is in the fluidcontainer. Returns null if none could be found | ||
* | ||
* @param pItemStack | ||
* @return | ||
*/ | ||
public static Fluid getFluidFromContainer(ItemStack pItemStack) | ||
{ | ||
Fluid tReturnVal = null; | ||
|
||
if ((Object)pItemStack.getItem() instanceof IFluidContainerItem) | ||
{ | ||
IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast(pItemStack.getItem()); | ||
FluidStack tContents = tFluidContainer.getFluid(pItemStack); | ||
if (tContents != null) | ||
{ | ||
tReturnVal = tContents.getFluid(); | ||
} | ||
} | ||
|
||
return tReturnVal; | ||
} | ||
|
||
/** Convert Minecraft <modID>:<itemID>:<metaID> notation into an actual Item-class | ||
* | ||
* @param pItemIdentifier | ||
* @return | ||
*/ | ||
public static Item ConvertStringToItem(String pItemIdentifier) | ||
{ | ||
String[] args = pItemIdentifier.split(":"); | ||
String tMod; | ||
String tName; | ||
int tMeta; | ||
|
||
if (args.length >= 2) | ||
{ | ||
tMod = args[0]; | ||
tName = args[1]; | ||
if (args.length == 3) | ||
tMeta = Integer.parseInt(args[2]); | ||
else | ||
tMeta = 0; | ||
|
||
Item tItem = GameRegistry.findItem(tMod, tName); | ||
if (tItem != null) | ||
return tItem; | ||
else | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
/** Convert item instance to string notation (UNTESTED!) | ||
* | ||
* @param pItem | ||
* @return | ||
*/ | ||
public static String ConvertItemToString(Item pItem) | ||
{ | ||
String tRet = ""; | ||
UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(pItem); | ||
if (uid != null) | ||
tRet = uid.toString(); | ||
|
||
return tRet; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.