Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show EEC current mob in WAILA and tricorder #3776

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.UUID;

Expand All @@ -60,11 +61,13 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
Expand Down Expand Up @@ -126,6 +129,8 @@
import kubatech.client.effect.EntityRenderer;
import kubatech.loaders.MobHandlerLoader;
import kubatech.network.CustomTileEntityPacket;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;

public class MTEExtremeEntityCrusher extends KubaTechGTMultiBlockBase<MTEExtremeEntityCrusher>
implements CustomTileEntityPacketHandler, ISurvivalConstructable {
Expand Down Expand Up @@ -657,6 +662,8 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
@Override
public String[] getInfoData() {
ArrayList<String> info = new ArrayList<>(Arrays.asList(super.getInfoData()));
String mobName = getCurrentMob();
info.add("Current Mob: " + EnumChatFormatting.YELLOW + (mobName != null ? mobName : "None"));
info.add("Animations: " + EnumChatFormatting.YELLOW + (mAnimationEnabled ? "Enabled" : "Disabled"));
info.add(
"Is allowed to produce infernal drops: " + EnumChatFormatting.YELLOW
Expand Down Expand Up @@ -773,6 +780,50 @@ protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_EXTREME_ENTITY_CRUSHER_LOOP;
}

private String getCurrentMob() {
ItemStack spawner = mInventory[1];
if (spawner != null && spawner.getTagCompound() != null) {
return spawner.getTagCompound()
.getString("mobType");
}
return null;
}

@Override
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
super.getWailaNBTData(player, tile, tag, world, x, y, z);
String mob = getCurrentMob();
if (mob != null) {
tag.setString("eecMobType", mob);
}
}

@Override
public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
super.getWailaBody(itemStack, currentTip, accessor, config);
NBTTagCompound tag = accessor.getNBTData();

if (tag.hasKey("eecMobType", Constants.NBT.TAG_STRING)) {
String mob = tag.getString("eecMobType");
String mobKey = "entity." + mob + ".name";
if (StatCollector.canTranslate(mobKey)) {
currentTip.add(
StatCollector.translateToLocalFormatted(
"kubatech.waila.eec.mob_type",
StatCollector.translateToLocal(mobKey)));
} else {
currentTip.add(StatCollector.translateToLocalFormatted("kubatech.waila.eec.mob_type", mob));
}
} else {
currentTip.add(
StatCollector.translateToLocalFormatted(
"kubatech.waila.eec.mob_type",
StatCollector.translateToLocal("kubatech.waila.eec.no_mob")));
}
}

private static class EECFakePlayer extends FakePlayer {

MTEExtremeEntityCrusher mte;
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/kubatech/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kubatech.commandhandler.invalid=§cInvalid use ! The proper use of this command
kubatech.commandhandler.cant_find=§cCan't find command option %s
kubatech.commandhandler.generic_help=§cYou can also use "/kubatech help" to get possible commands
kubatech.commandhandler.usage=<option>
kubatech.command.help.possible_commands=Possible commands:
kubatech.command.help.possible_commands=Possible commands:
kubatech.command.help.usage=- Shows all possible commands
kubatech.command.config.invalid_option=§cInvalid option ! Possible options: reload
kubatech.command.config.success=§aConfig reloaded successfully !
Expand All @@ -37,6 +37,10 @@ GT5U.gui.text.EIG_seedOverflow=Too many seeds inside!
GT5U.gui.text.EIG_missingwater=No water!
GT5U.gui.text.EIG_ic2glass=Insufficient glass tier!

#Waila
kubatech.waila.eec.mob_type=Mob Type: %s
kubatech.waila.eec.no_mob=None

#Blocks
kubablock.tea_acceptor.name=§4§lTea Acceptor
kubablock.tea_storage.name=§4§lTea Storage Extender
Expand Down
Loading