mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Spawner Changer
This commit is contained in:
parent
8e8b59034b
commit
c7f5455862
7 changed files with 134 additions and 0 deletions
|
@ -35,6 +35,8 @@ public class ConfigValues{
|
|||
|
||||
public static String[] repairerExtraWhitelist;
|
||||
|
||||
public static String[] spawnerChangerBlacklist;
|
||||
|
||||
public static boolean lessSound;
|
||||
public static boolean lessParticles;
|
||||
public static boolean lessBlockBreakingEffects;
|
||||
|
@ -60,6 +62,7 @@ public class ConfigValues{
|
|||
minerExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Extra Whitelist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode.").getStringList();
|
||||
minerBlacklist = config.get(ConfigCategories.MACHINE_VALUES.name, "Vertical Digger Blacklist", new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes.").getStringList();
|
||||
repairerExtraWhitelist = config.get(ConfigCategories.MACHINE_VALUES.name, "Item Repairer Extra Whitelist", new String[]{"tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver"}, "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable.").getStringList();
|
||||
spawnerChangerBlacklist = config.get(ConfigCategories.OTHER.name, "Spawner Changer Blacklist", new String[]{"VillagerGolem"}, "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here.").getStringList();
|
||||
|
||||
lessSound = config.get(ConfigCategories.PERFORMANCE.name, "Less Sound", false, "If blocks in Actually Additions should have less sounds").getBoolean();
|
||||
lessParticles = config.get(ConfigCategories.PERFORMANCE.name, "Less Particles", false, "If blocks in Actually Additions should have less particles").getBoolean();
|
||||
|
|
|
@ -105,6 +105,7 @@ public class ItemCrafting{
|
|||
//Clearing NBT Storage
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemLaserWrench), new ItemStack(InitItems.itemLaserWrench));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPhantomConnector), new ItemStack(InitItems.itemPhantomConnector));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemSpawnerChanger), new ItemStack(InitItems.itemSpawnerChanger));
|
||||
|
||||
//Chest To Crate Upgrade
|
||||
if(ConfigCrafting.CHEST_TO_CRATE_UPGRADE.isEnabled()){
|
||||
|
|
|
@ -133,6 +133,8 @@ public class InitItems{
|
|||
public static Item itemChestToCrateUpgrade;
|
||||
public static Item itemCrateKeeper;
|
||||
|
||||
public static Item itemSpawnerChanger;
|
||||
|
||||
public static Item itemLaserWrench;
|
||||
public static Item itemCrystal;
|
||||
public static Item itemColorLens;
|
||||
|
@ -210,6 +212,7 @@ public class InitItems{
|
|||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
||||
itemSpawnerChanger = new ItemSpawnerChanger("itemSpawnerChanger");
|
||||
itemMisc = new ItemMisc("itemMisc");
|
||||
itemCrateKeeper = new ItemGeneric("itemCrateKeeper");
|
||||
itemColorLens = new ItemLens("itemColorLens", Lenses.LENS_COLOR);
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
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.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSpawnerChanger extends ItemBase{
|
||||
|
||||
public ItemSpawnerChanger(String name){
|
||||
super(name);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack aStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
if(!world.isRemote){
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if(player.canPlayerEdit(pos.offset(facing), facing, stack)){
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof TileEntityMobSpawner){
|
||||
String entity = this.getStoredEntity(stack);
|
||||
if(entity != null){
|
||||
MobSpawnerBaseLogic logic = ((TileEntityMobSpawner)tile).getSpawnerBaseLogic();
|
||||
logic.setEntityName(entity);
|
||||
|
||||
tile.markDirty();
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
|
||||
ItemPhantomConnector.clearStorage(stack);
|
||||
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
stack.stackSize--;
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){
|
||||
if(!player.worldObj.isRemote){
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if(this.getStoredEntity(stack) == null){
|
||||
if(this.storeClickedEntity(stack, entity)){
|
||||
entity.setDead();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean storeClickedEntity(ItemStack stack, Entity entity){
|
||||
if(!entity.worldObj.isRemote){
|
||||
if(!stack.hasTagCompound()){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
if(entityName != null && !entityName.isEmpty()){
|
||||
for(String name : ConfigValues.spawnerChangerBlacklist){
|
||||
if(entityName.equals(name)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("Entity", entityName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getStoredEntity(ItemStack stack){
|
||||
if(stack.hasTagCompound()){
|
||||
String entity = stack.getTagCompound().getString("Entity");
|
||||
if(entity != null && !entity.isEmpty()){
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
String entity = this.getStoredEntity(stack);
|
||||
if(entity != null){
|
||||
list.add("Entity: "+entity);
|
||||
list.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".clearStorage.desc"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -410,6 +410,7 @@ item.actuallyadditions.itemPaxelCrystalWhite.name=Enori Crystal AIOT
|
|||
item.actuallyadditions.itemPaxelCrystalGreen.name=Emeradic Crystal AIOT
|
||||
item.actuallyadditions.itemFoodBacon.name=Bacon
|
||||
item.actuallyadditions.itemMiscEnderStar.name=Ender Star
|
||||
item.actuallyadditions.itemSpawnerChanger.name=Spawner Changer
|
||||
|
||||
#Tooltips
|
||||
tooltip.actuallyadditions.onSuffix.desc=On
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "actuallyadditions:item/standardItem",
|
||||
"textures": {
|
||||
"layer0": "actuallyadditions:items/itemSpawnerChanger"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 532 B |
Loading…
Reference in a new issue