Skip to content

Commit

Permalink
1.12.2 - long-overdue fixes (#30)
Browse files Browse the repository at this point in the history
* Collapse duplicates in creative menu and JEI

* Add vanilla provider for MobSpawner, prevent waila error from consuming the universe

* Use TextComponentTranslation to localize spawner probedata clientside
  • Loading branch information
falkreon authored and unascribed committed Apr 27, 2018
1 parent f1b28e3 commit 8f323a8
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ private.properties
minecraft
.idea
*.iml

#Extra stuff for Falk's dumb compy
.directory
17 changes: 13 additions & 4 deletions src/main/java/com/elytradev/fruitphone/FruitRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ private static List<IProbeData> injectWailaData(List<IProbeData> data) {

ItemStack stack = mdp.identifyBlockHighlight(world, player, rtr, dac);
if (stack == null || stack.isEmpty()) {
stack = data.get(0).getInventory().get(0);
if (!data.isEmpty() && data.get(0).hasInventory() && !data.get(0).getInventory().isEmpty()) {
stack = data.get(0).getInventory().get(0);
}
} else {
((ProbeData)data.get(0))
.withInventory(ImmutableList.of(stack))
Expand All @@ -573,15 +575,22 @@ private static List<IProbeData> injectWailaData(List<IProbeData> data) {

int idx = 1;
for (String s : wailaHead) {
if ("<ERROR>".equals(s)) s = I18n.format("fruitphone.wailaError");
if ("<ERROR>".equals(s)) {
s = I18n.format("fruitphone.wailaError");
}

data.add(idx++, new ProbeData(s));
}
for (String s : wailaBody) {
if ("<ERROR>".equals(s)) s = I18n.format("fruitphone.wailaError");
if ("<ERROR>".equals(s)) {
s = I18n.format("fruitphone.wailaError");
}
data.add(idx++, new ProbeData(s));
}
for (String s : wailaTail) {
if ("<ERROR>".equals(s)) s = I18n.format("fruitphone.wailaError");
if ("<ERROR>".equals(s)) {
s = I18n.format("fruitphone.wailaError");
}
data.add(new ProbeData(s));
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static boolean doOresExist(String... ores) {
}

private static void colorRecipe(IForgeRegistry<IRecipe> registry, int color, Object... ingredients) {
craftableColors.add(color);
if (!craftableColors.contains(color)) craftableColors.add(color);

NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("fruitphone:color", color);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.elytradev.fruitphone.vanilla;

import java.util.List;

import com.elytradev.probe.api.IProbeData;
import com.elytradev.probe.api.impl.ProbeData;
import com.google.common.collect.ImmutableList;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

public class MobSpawnerDataProvider implements VanillaDataProvider<TileEntityMobSpawner> {

@Override
public void provideProbeData(TileEntityMobSpawner te, List<IProbeData> li) {
NBTTagCompound tag = new NBTTagCompound();
te.writeToNBT(tag);
NBTTagCompound spawnData = tag.getCompoundTag("SpawnData");
if (spawnData.hasKey("id")) {
String entityId = spawnData.getString("id");
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entityId));

TextComponentTranslation title = new TextComponentTranslation("fruitphone.mobSpawner.title", new TextComponentTranslation("entity."+entry.getName()+".name"), new TextComponentTranslation("tile.mobSpawner.name"));

li.add(new ProbeData()
.withInventory(ImmutableList.of(new ItemStack(Blocks.MOB_SPAWNER)))
.withLabel(title));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.tileentity.TileEntityNote;

import java.util.List;
Expand Down Expand Up @@ -61,6 +62,7 @@ public static <T extends TileEntity> void provideProbeData(T te, List<IProbeData
map.put(TileEntityJukebox.class, new JukeboxDataProvider());
map.put(TileEntityNote.class, new NoteBlockDataProvider());
map.put(TileEntityBeacon.class, new BeaconDataProvider());
map.put(TileEntityMobSpawner.class, new MobSpawnerDataProvider());
}

}
2 changes: 2 additions & 0 deletions src/main/resources/assets/fruitphone/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ fruitphone.beacon.primary=Primary: %s %s
fruitphone.beacon.secondary=Secondary: %s %s
fruitphone.beacon.none=None

fruitphone.mobSpawner.title=%1$s %2$s

fruitphone.gui.snapToGuides=Snap to Guides
fruitphone.gui.clampRegion=Clamp Region
fruitphone.gui.restoreDefaults=Restore Defaults
Expand Down

0 comments on commit 8f323a8

Please sign in to comment.