Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored waila integration and added machine specific info
- Loading branch information
Showing
12 changed files
with
197 additions
and
94 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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/slimeknights/tmechworks/blocks/logic/IPlaceDirection.java
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package slimeknights.tmechworks.blocks.logic; | ||
|
||
public interface IPlaceDirection { | ||
void setPlaceDirectioni(int direction); | ||
void setPlaceDirection(int direction); | ||
} |
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,40 @@ | ||
package slimeknights.tmechworks.common; | ||
|
||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import slimeknights.mantle.pulsar.config.ForgeCFG; | ||
import slimeknights.tmechworks.TMechworks; | ||
|
||
public final class Config { | ||
public static ForgeCFG pulseConfig = new ForgeCFG("tmechworksModules", "Modules"); | ||
public static Config instance = new Config(); | ||
|
||
private Config(){} | ||
|
||
private static Configuration configFile; | ||
|
||
public static void load(FMLPreInitializationEvent event){ | ||
configFile = new Configuration(event.getSuggestedConfigurationFile(), "2.0", false); | ||
MinecraftForge.EVENT_BUS.register(instance); | ||
updateConfig(); | ||
} | ||
|
||
@SubscribeEvent | ||
public void update(ConfigChangedEvent.OnConfigChangedEvent event){ | ||
if(event.getModID().equals(TMechworks.modID)) { | ||
updateConfig(); | ||
} | ||
} | ||
|
||
public static void updateConfig(){ | ||
if(configFile.hasChanged()) { | ||
configFile.save(); | ||
} | ||
if(pulseConfig.getConfig().hasChanged()) { | ||
pulseConfig.flush(); | ||
} | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
src/main/java/slimeknights/tmechworks/integration/WailaIntegration.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
src/main/java/slimeknights/tmechworks/integration/waila/RedstoneMachineDataProvider.java
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,66 @@ | ||
package slimeknights.tmechworks.integration.waila; | ||
|
||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaDataProvider; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import slimeknights.tmechworks.blocks.logic.DrawbridgeLogic; | ||
import slimeknights.tmechworks.blocks.logic.DrawbridgeLogicBase; | ||
import slimeknights.tmechworks.blocks.logic.FirestarterLogic; | ||
import slimeknights.tmechworks.blocks.logic.RedstoneMachineLogicBase; | ||
|
||
import java.util.List; | ||
|
||
public class RedstoneMachineDataProvider implements IWailaDataProvider | ||
{ | ||
@Override public ItemStack getWailaStack (IWailaDataAccessor accessor, IWailaConfigHandler config) | ||
{ | ||
return null; | ||
} | ||
|
||
@Override public List<String> getWailaHead (ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) | ||
{ | ||
return currenttip; | ||
} | ||
|
||
@Override public List<String> getWailaBody (ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) | ||
{ | ||
if (config.getConfig(WailaRegistrar.CONFIG_REDSTONE_MACHINE) && accessor.getTileEntity() instanceof RedstoneMachineLogicBase) | ||
{ | ||
RedstoneMachineLogicBase logicBase = (RedstoneMachineLogicBase) accessor.getTileEntity(); | ||
|
||
currenttip.add(I18n.format("hud.msg.power") + ": " + logicBase.getRedstoneState()); | ||
|
||
if(logicBase instanceof DrawbridgeLogicBase){ | ||
DrawbridgeLogicBase logic = (DrawbridgeLogicBase) logicBase; | ||
DrawbridgeLogicBase.DrawbridgeStats stats = logic.getStats(); | ||
|
||
currenttip.add(I18n.format("hud.msg.state") + ": " + I18n.format("tmechworks.hud.state.drawbridge." + (logic.getExtending() ? "extending" : logic.getExtended() ? "extended" : "retracted")) + " " + I18n.format("tmechworks.hud.state.drawbridge.length", logic.getExtendState())); | ||
currenttip.add(I18n.format("tmechworks.machine.stats")); | ||
currenttip.add(I18n.format("tmechworks.drawbridge.stats.length", stats.extendLength)); | ||
currenttip.add(I18n.format("tmechworks.drawbridge.stats.delay", stats.extendDelay)); | ||
} else if(logicBase instanceof FirestarterLogic){ | ||
FirestarterLogic logic = (FirestarterLogic) logicBase; | ||
currenttip.add(I18n.format("tmechworks.hud.behaviour") + ": " + I18n.format("tmechworks.hud.behaviour.firestarter." + (logic.getShouldExtinguish() ? "extinguish" : "keep"))); | ||
} | ||
} | ||
|
||
return currenttip; | ||
} | ||
|
||
@Override public List<String> getWailaTail (ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) | ||
{ | ||
return currenttip; | ||
} | ||
|
||
@Override public NBTTagCompound getNBTData (EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) | ||
{ | ||
return tag; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/slimeknights/tmechworks/integration/waila/Waila.java
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,34 @@ | ||
package slimeknights.tmechworks.integration.waila; | ||
|
||
import com.google.common.eventbus.Subscribe; | ||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaDataProvider; | ||
import mcp.mobius.waila.api.IWailaRegistrar; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.common.event.FMLInterModComms; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import slimeknights.mantle.pulsar.pulse.Pulse; | ||
import slimeknights.tmechworks.TMechworks; | ||
import slimeknights.tmechworks.blocks.logic.DrawbridgeLogicBase; | ||
import slimeknights.tmechworks.blocks.logic.RedstoneMachineLogicBase; | ||
import slimeknights.tmechworks.library.Util; | ||
|
||
import java.util.List; | ||
|
||
@Pulse(id = "wailaIntegration", modsRequired = Waila.modid, defaultEnable = true) | ||
public class Waila | ||
{ | ||
public static final String modid = "waila"; | ||
|
||
@Subscribe | ||
public void preInit(FMLPreInitializationEvent event) { | ||
FMLInterModComms.sendMessage("waila", "register", "slimeknights.tmechworks.integration.waila.WailaRegistrar.wailaCallback"); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/slimeknights/tmechworks/integration/waila/WailaRegistrar.java
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,16 @@ | ||
package slimeknights.tmechworks.integration.waila; | ||
|
||
import mcp.mobius.waila.api.IWailaRegistrar; | ||
import slimeknights.tmechworks.TMechworks; | ||
import slimeknights.tmechworks.blocks.logic.RedstoneMachineLogicBase; | ||
import slimeknights.tmechworks.library.Util; | ||
|
||
public class WailaRegistrar { | ||
static final String CONFIG_REDSTONE_MACHINE = Util.prefix("redstoneMachine"); | ||
|
||
public static void wailaCallback(IWailaRegistrar registrar){ | ||
registrar.addConfig(TMechworks.modName, CONFIG_REDSTONE_MACHINE, true); | ||
|
||
registrar.registerBodyProvider(new RedstoneMachineDataProvider(), RedstoneMachineLogicBase.class); | ||
} | ||
} |
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