Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

Commit df371ff

Browse files
committed
Add meta providers for several entity-capture items
- Cyclic's Monster Ball - Not Enough Wand's Capturing Wand - Industrial Foregoing's Mob Imprisonment Tool - Extra Utilities 2's Gold Lasso & Cursed Lasso Fixes #185. There's most definitely not any other mods which add this functionality, no sirree!
1 parent 0fc804a commit df371ff

File tree

6 files changed

+279
-5
lines changed

6 files changed

+279
-5
lines changed

build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ repositories {
5858

5959
maven { url 'http://chickenbones.net/maven/' } // CBMP
6060
maven { url 'http://dvs1.progwml6.com/files/maven/' } // JEI + Tinker's
61+
maven { url 'http://dyonovan.com/maven2/' } // Industrial Foregoing
6162
maven { url 'http://maven.ic2.player.to/' } // IC2 + Forestry
6263
maven { url 'https://dl.bintray.com/squiddev/maven/' } // ConfigGen (why do I use this still?)
6364
maven { url 'https://maven.amadornes.com/' } // Multipart
6465
maven { url 'https://maven.blamejared.com/' } // Botania
6566
maven { url 'https://maven.covers1624.net/' } // CoFH
6667
maven { url 'https://maven.k-4u.nl/' } // McJty's mods
6768
maven { url 'https://maven.mcmoddev.com/' } // Tesla
69+
maven { url 'https://maven.shadowfacts.net' } // Forgelin
6870
maven { url 'https://maven.tterrag.com/' } // EnderCore
6971
maven { url 'https://maven2.tterrag.com/' } // EnderIO
7072
maven { url 'https://mod-buildcraft.com/maven/' } // Buildcraft
@@ -89,6 +91,7 @@ dependencies {
8991
integrationMod "cofh:ThermalExpansion:1.12.2-5.5.3.41:universal"
9092
integrationMod "cofh:ThermalFoundation:1.12.2-2.6.2.26:universal"
9193
integrationMod "cofh:CoFHWorld:1.12.2-1.3.0.6:universal"
94+
integrationMod("com.buuz135.industrial.IndustrialForegoing:industrialforegoing:1.12.2-1.5.13-136") { exclude group: "mezz.jei" }
9295
compileOnly ("com.enderio:EnderIO:1.12.2-5.0.43") { transitive = false }
9396
compileOnly "com.enderio.core:EnderCore:1.12.2-0.5.57" // EnderCore appears to crash in a development environment.
9497
integrationMod("com.github.mcjty:mcjtylib:1.12-3.5.0") { transitive = false }
@@ -105,6 +108,7 @@ dependencies {
105108
integrationMod "slimeknights:TConstruct:1.12.2-2.12.0.116"
106109
integrationMod "slimeknights.mantle:Mantle:1.12-1.3.3.51"
107110
integrationMod "vazkii.botania:Botania:r1.10-362.77"
111+
integrationMod "net.ndrei:tesla-core-lib:1.12.2-1.0.15.16:deobf"
108112

109113
// All the Curse mods
110114
integrationMod "baubles:Baubles:1.12:1.5.2"
@@ -115,6 +119,9 @@ dependencies {
115119
integrationMod "roost:roost:1.12:1.3.0"
116120
integrationMod "chickens:chickens:6.0.4"
117121
integrationMod "hatchery:hatchery:1.12.2:2.2.1"
122+
integrationMod "cyclic:Cyclic:1.12.2:1.19.9"
123+
integrationMod "extra-utilities:extrautils2:1.12:1.9.9"
124+
integrationMod "not-enough-wands:notenoughwands:1.12:1.8.1"
118125

119126
compileOnly('org.squiddev:ConfigGen:1.2.5') { exclude group: 'net.minecraftforge' }
120127

@@ -172,9 +179,10 @@ curseforge {
172179
}
173180

174181
task runTestServer(type: JavaExec) {
175-
classpath = sourceSets.test.runtimeClasspath
176-
main = "org.squiddev.plethora.boostrap.LaunchServer"
177-
workingDir = "${project.projectDir}/test-files/server"
182+
classpath = sourceSets.test.runtimeClasspath
183+
main = "org.squiddev.plethora.boostrap.LaunchServer"
184+
workingDir = "${project.projectDir}/test-files/server"
185+
systemProperties = ["fml.queryResult": "confirm"]
178186

179-
workingDir.mkdirs()
187+
workingDir.mkdirs()
180188
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.squiddev.plethora.integration.cyclic;
2+
3+
import com.lothrazar.cyclicmagic.item.mobcapture.ItemProjectileMagicNet;
4+
import com.lothrazar.cyclicmagic.util.Const;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.EntityList;
7+
import net.minecraft.entity.passive.EntitySquid;
8+
import net.minecraft.item.Item;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.nbt.NBTTagCompound;
11+
import net.minecraft.util.ResourceLocation;
12+
import net.minecraftforge.common.util.Constants;
13+
import net.minecraftforge.fml.common.registry.ForgeRegistries;
14+
import org.squiddev.plethora.api.IWorldLocation;
15+
import org.squiddev.plethora.api.Injects;
16+
import org.squiddev.plethora.api.meta.IMetaProvider;
17+
import org.squiddev.plethora.integration.ItemEntityStorageMetaProvider;
18+
import org.squiddev.plethora.utils.WorldDummy;
19+
20+
import javax.annotation.Nonnull;
21+
import javax.annotation.Nullable;
22+
import java.util.Map;
23+
24+
import static com.lothrazar.cyclicmagic.item.mobcapture.ItemProjectileMagicNet.NBT_ENTITYID;
25+
26+
@Injects(Const.MODID)
27+
public final class IntegrationCyclic {
28+
public static final IMetaProvider<ItemStack> META_MONSTER_NET = new ItemEntityStorageMetaProvider<ItemProjectileMagicNet>(
29+
"capturedEntity", ItemProjectileMagicNet.class,
30+
"Provides the entity captured inside this monster net."
31+
) {
32+
@Nullable
33+
@Override
34+
protected Entity spawn(@Nonnull ItemStack stack, @Nonnull ItemProjectileMagicNet item, @Nonnull IWorldLocation location) {
35+
NBTTagCompound entityData = stack.getTagCompound();
36+
if (entityData == null || !entityData.hasKey(NBT_ENTITYID, Constants.NBT.TAG_STRING)) return null;
37+
return EntityList.createEntityFromNBT(entityData, location.getWorld());
38+
}
39+
40+
@Nonnull
41+
@Override
42+
protected Map<String, ?> getBasicDetails(@Nonnull ItemStack stack, @Nonnull ItemProjectileMagicNet item) {
43+
return getBasicDetails(stack.getTagCompound());
44+
}
45+
46+
@Nullable
47+
@Override
48+
public ItemStack getExample() {
49+
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Const.MODID, "magic_net"));
50+
if (!(item instanceof ItemProjectileMagicNet)) return null;
51+
52+
ItemStack stack = new ItemStack(item);
53+
NBTTagCompound tag = new NBTTagCompound();
54+
Entity entity = new EntitySquid(WorldDummy.INSTANCE);
55+
entity.writeToNBT(tag);
56+
tag.setString(NBT_ENTITYID, EntityList.getKey(entity.getClass()).toString());
57+
stack.setTagCompound(tag);
58+
return stack;
59+
}
60+
};
61+
62+
private IntegrationCyclic() {
63+
}
64+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.squiddev.plethora.integration.extrautilities;
2+
3+
import com.rwtema.extrautils2.ExtraUtils2;
4+
import com.rwtema.extrautils2.items.ItemGoldenLasso;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.EntityList;
7+
import net.minecraft.entity.passive.EntitySquid;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.nbt.NBTTagCompound;
10+
import net.minecraftforge.common.util.Constants;
11+
import org.squiddev.plethora.api.IWorldLocation;
12+
import org.squiddev.plethora.api.Injects;
13+
import org.squiddev.plethora.api.meta.IMetaProvider;
14+
import org.squiddev.plethora.integration.ItemEntityStorageMetaProvider;
15+
16+
import javax.annotation.Nonnull;
17+
import javax.annotation.Nullable;
18+
import java.util.Map;
19+
20+
import static com.rwtema.extrautils2.items.ItemGoldenLasso.NBT_ANIMAL;
21+
22+
@Injects(ExtraUtils2.MODID)
23+
public final class IntegrationExtraUtilities {
24+
public static final IMetaProvider<ItemStack> META_MONSTER_NET = new ItemEntityStorageMetaProvider<ItemGoldenLasso>(
25+
"capturedEntity", ItemGoldenLasso.class,
26+
"Provides the entity captured inside this lasso."
27+
) {
28+
@Nullable
29+
@Override
30+
protected Entity spawn(@Nonnull ItemStack stack, @Nonnull ItemGoldenLasso item, @Nonnull IWorldLocation location) {
31+
NBTTagCompound tag = stack.getTagCompound();
32+
if (tag == null || !tag.hasKey(NBT_ANIMAL, Constants.NBT.TAG_COMPOUND)) return null;
33+
34+
NBTTagCompound entityData = tag.getCompoundTag(NBT_ANIMAL);
35+
if (!entityData.hasKey("id", Constants.NBT.TAG_STRING)) return null;
36+
37+
return EntityList.createEntityFromNBT(entityData, location.getWorld());
38+
}
39+
40+
@Nonnull
41+
@Override
42+
protected Map<String, ?> getBasicDetails(@Nonnull ItemStack stack, @Nonnull ItemGoldenLasso item) {
43+
return getBasicDetails(stack.getTagCompound());
44+
}
45+
46+
@Nonnull
47+
@Override
48+
public ItemStack getExample() {
49+
return ItemGoldenLasso.newCraftingStack(EntitySquid.class);
50+
}
51+
};
52+
53+
private IntegrationExtraUtilities() {
54+
}
55+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.squiddev.plethora.integration.industrialforegoing;
2+
3+
import com.buuz135.industrial.item.MobImprisonmentToolItem;
4+
import com.buuz135.industrial.proxy.ItemRegistry;
5+
import com.buuz135.industrial.utils.Reference;
6+
import net.minecraft.entity.Entity;
7+
import net.minecraft.entity.EntityList;
8+
import net.minecraft.entity.passive.EntitySquid;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.nbt.NBTTagCompound;
11+
import net.minecraft.util.ResourceLocation;
12+
import org.squiddev.plethora.api.IWorldLocation;
13+
import org.squiddev.plethora.api.Injects;
14+
import org.squiddev.plethora.api.meta.IMetaProvider;
15+
import org.squiddev.plethora.integration.ItemEntityStorageMetaProvider;
16+
import org.squiddev.plethora.utils.WorldDummy;
17+
18+
import javax.annotation.Nonnull;
19+
import javax.annotation.Nullable;
20+
import java.util.Collections;
21+
import java.util.Map;
22+
23+
@Injects(Reference.MOD_ID)
24+
public final class IntegrationIF {
25+
public static final IMetaProvider<ItemStack> META_MOB_IMPRISONMENT = new ItemEntityStorageMetaProvider<MobImprisonmentToolItem>(
26+
"capturedEntity", MobImprisonmentToolItem.class,
27+
"Provides the entity captured inside this mob imprisonment tool."
28+
) {
29+
@Nullable
30+
@Override
31+
protected Entity spawn(@Nonnull ItemStack stack, @Nonnull MobImprisonmentToolItem item, @Nonnull IWorldLocation location) {
32+
return item.containsEntity(stack) ? item.getEntityFromStack(stack, location.getWorld(), true) : null;
33+
}
34+
35+
@Nonnull
36+
@Override
37+
protected Map<String, ?> getBasicDetails(@Nonnull ItemStack stack, @Nonnull MobImprisonmentToolItem item) {
38+
return item.containsEntity(stack)
39+
? getBasicDetails(new ResourceLocation(item.getID(stack)), stack.getTagCompound())
40+
: Collections.emptyMap();
41+
}
42+
43+
@Nonnull
44+
@Override
45+
public ItemStack getExample() {
46+
ItemStack stack = new ItemStack(ItemRegistry.mobImprisonmentToolItem);
47+
Entity entity = new EntitySquid(WorldDummy.INSTANCE);
48+
NBTTagCompound tag = new NBTTagCompound();
49+
tag.setString("entity", EntityList.getKey(entity).toString());
50+
tag.setInteger("id", EntityList.getID(entity.getClass()));
51+
entity.writeToNBT(tag);
52+
stack.setTagCompound(tag);
53+
return stack;
54+
}
55+
};
56+
57+
private IntegrationIF() {
58+
}
59+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.squiddev.plethora.integration.notenoughwands;
2+
3+
import net.minecraft.entity.Entity;
4+
import net.minecraft.entity.EntityLivingBase;
5+
import net.minecraft.entity.passive.EntitySquid;
6+
import net.minecraft.item.ItemStack;
7+
import net.minecraft.nbt.NBTTagCompound;
8+
import net.minecraft.world.World;
9+
import net.minecraftforge.common.util.Constants;
10+
import net.minecraftforge.fml.common.registry.EntityEntry;
11+
import net.minecraftforge.fml.common.registry.EntityRegistry;
12+
import org.squiddev.plethora.api.IWorldLocation;
13+
import org.squiddev.plethora.api.Injects;
14+
import org.squiddev.plethora.api.meta.IMetaProvider;
15+
import org.squiddev.plethora.integration.ItemEntityStorageMetaProvider;
16+
import romelo333.notenoughwands.Items.CapturingWand;
17+
import romelo333.notenoughwands.ModItems;
18+
import romelo333.notenoughwands.NotEnoughWands;
19+
20+
import javax.annotation.Nonnull;
21+
import javax.annotation.Nullable;
22+
import java.util.Collections;
23+
import java.util.Map;
24+
25+
@Injects(NotEnoughWands.MODID)
26+
public final class IntegrationNEW {
27+
public static final IMetaProvider<ItemStack> META_CAPTURING_WAND = new ItemEntityStorageMetaProvider<CapturingWand>(
28+
"capturedEntity", CapturingWand.class,
29+
"Provides the entity captured inside this capturing wand."
30+
) {
31+
@Nullable
32+
@Override
33+
protected Entity spawn(@Nonnull ItemStack stack, @Nonnull CapturingWand item, @Nonnull IWorldLocation location) {
34+
NBTTagCompound tag = stack.getTagCompound();
35+
if (tag == null || !tag.hasKey("type", Constants.NBT.TAG_STRING)) return null;
36+
37+
Class<? extends EntityLivingBase> type = getClass(tag.getString("type"));
38+
if (type == null) return null;
39+
40+
EntityLivingBase entity;
41+
try {
42+
entity = type.getConstructor(World.class).newInstance(location.getWorld());
43+
} catch (ReflectiveOperationException | RuntimeException e) {
44+
return null;
45+
}
46+
47+
entity.readEntityFromNBT(tag.getCompoundTag("mob"));
48+
return entity;
49+
}
50+
51+
@Nonnull
52+
@Override
53+
protected Map<String, ?> getBasicDetails(@Nonnull ItemStack stack, @Nonnull CapturingWand item) {
54+
NBTTagCompound tag = stack.getTagCompound();
55+
if (tag == null || !tag.hasKey("type", Constants.NBT.TAG_STRING)) return Collections.emptyMap();
56+
57+
Class<? extends EntityLivingBase> type = getClass(tag.getString("type"));
58+
if (type == null) return Collections.emptyMap();
59+
60+
EntityEntry entry = EntityRegistry.getEntry(type);
61+
if (entry == null) return Collections.emptyMap();
62+
63+
return getBasicDetails(entry.getRegistryName(), tag.getCompoundTag("mob"));
64+
}
65+
66+
@Nullable
67+
private Class<? extends EntityLivingBase> getClass(String type) {
68+
try {
69+
return Class.forName(type).asSubclass(EntityLivingBase.class);
70+
} catch (ReflectiveOperationException ignored) {
71+
return null;
72+
}
73+
}
74+
75+
@Nonnull
76+
@Override
77+
public ItemStack getExample() {
78+
ItemStack stack = new ItemStack(ModItems.capturingWand);
79+
NBTTagCompound tag = new NBTTagCompound();
80+
tag.setString("type", EntitySquid.class.getName());
81+
stack.setTagCompound(tag);
82+
return stack;
83+
}
84+
};
85+
86+
private IntegrationNEW() {
87+
}
88+
}

src/test/resources/assets/plethora-test/test-rom/spec/vanilla/inventory_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("inventories", function()
2828

2929
it("on a stick", function()
3030
local inv = setup()
31-
expect(inv.getItemMeta(1)):same {
31+
expect(inv.getItemMeta(1)):matches {
3232
name = "minecraft:stick", displayName = "Stick", rawName = "item.stick",
3333
damage = 0, maxDamage = 0, count = 50, maxCount = 64,
3434
ores = { stickWood = true }

0 commit comments

Comments
 (0)