Merge branch 'dev'

This commit is contained in:
JackCarterSmith 2019-04-27 23:21:23 +02:00
commit 1ac202da07
20 changed files with 595 additions and 12 deletions

View File

@ -15,9 +15,17 @@ buildscript {
} }
} }
repositories {
jcenter()
maven {
name="bbm"
url="http://api.dmodoomsirius.me/"
}
}
apply plugin: 'forge' apply plugin: 'forge'
version = "0.1.1" version = "0.1.2"
group = "fr.jcs.bigalarm" group = "fr.jcs.bigalarm"
archivesBaseName = "BigAlarm" archivesBaseName = "BigAlarm"
@ -28,7 +36,7 @@ targetCompatibility = 1.7
minecraft { minecraft {
version = "1.7.10-10.13.4.1566-1.7.10" version = "1.7.10-10.13.4.1566-1.7.10"
replace '${version}', project.version replace '${version}', project.version
mappings = 'stable_12' mappings = 'snapshot_20140925'
runDir = "eclipse" runDir = "eclipse"
} }
@ -46,6 +54,10 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
//compile 'com.google.code.findbugs:jsr305:3.0.0'
testCompile 'junit:junit:4.11'
compile "com.builtbroken.codinglib:CodingLib:0.+"
compile "com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.+:deobf"
} }
processResources processResources

View File

@ -5,18 +5,22 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import fr.jcs.bigalarm.blocks.AlarmBlock; import fr.jcs.bigalarm.blocks.AlarmBlock;
import fr.jcs.bigalarm.proxy.CommonProxy; import fr.jcs.bigalarm.proxy.CommonProxy;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@Mod(modid = BigAlarmRefs.MOD_ID, name = BigAlarmRefs.MOD_NAME, version = "@VERSION@", canBeDeactivated = false, dependencies = "required-after:Forge@[10.13.4.1566,)") @Mod(modid = BigAlarmRefs.MOD_ID, name = BigAlarmRefs.MOD_NAME, version = "@VERSION@", canBeDeactivated = false, dependencies = "required-after:Forge@[10.13.4.1566,)")
public class BigAlarm { public class BigAlarm {
@Instance @Instance(BigAlarmRefs.MOD_ID)
public static BigAlarm instance; public static BigAlarm instance = new BigAlarm();
@SidedProxy(clientSide = BigAlarmRefs.PROXY_CLIENT, serverSide = BigAlarmRefs.PROXY_SERVER) @SidedProxy(clientSide = BigAlarmRefs.PROXY_CLIENT, serverSide = BigAlarmRefs.PROXY_SERVER)
public static CommonProxy proxy; public static CommonProxy proxy;
public static final SimpleNetworkWrapper netWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(BigAlarmRefs.MOD_ID);
public static AlarmBlock alarmBlock; public static AlarmBlock alarmBlock;
@ -24,6 +28,7 @@ public class BigAlarm {
public void preInit(FMLInitializationEvent event) public void preInit(FMLInitializationEvent event)
{ {
System.out.println("[BigAlarm]: Making nuut sound..."); System.out.println("[BigAlarm]: Making nuut sound...");
proxy.registerTileEntities();
} }
@EventHandler @EventHandler
@ -32,6 +37,7 @@ public class BigAlarm {
System.out.println("[BigAlarm]: Connecting speakers..."); System.out.println("[BigAlarm]: Connecting speakers...");
alarmBlock = new AlarmBlock(); alarmBlock = new AlarmBlock();
GameRegistry.registerBlock(alarmBlock, "alarmBlock"); GameRegistry.registerBlock(alarmBlock, "alarmBlock");
//netWrapper.registerMessage(messageHandler, requestMessageType, 0, Side.SERVER);
} }
@EventHandler @EventHandler

View File

@ -1,8 +1,16 @@
package fr.jcs.bigalarm; package fr.jcs.bigalarm;
import net.minecraft.launchwrapper.Launch;
public class BigAlarmRefs { public class BigAlarmRefs {
public static final String MOD_ID = "bigalarm"; public static final String MOD_ID = "bigalarm";
public static final String MOD_NAME = "BigAlarm"; public static final String MOD_NAME = "BigAlarm";
public static final String PROXY_CLIENT = "fr.jcs.bigalarm.proxy.ClientProxy"; public static final String PROXY_CLIENT = "fr.jcs.bigalarm.proxy.ClientProxy";
public static final String PROXY_SERVER = "fr.jcs.bigalarm.proxy.CommonProxy"; public static final String PROXY_SERVER = "fr.jcs.bigalarm.proxy.CommonProxy";
public static final boolean isDevEnv = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment");
public static final String RESOURCESPREFIX = MOD_ID.toLowerCase() + ":";
public static final String GUI = "gui." + MOD_ID + ".";
public static final int GUIID_AlarmBlock = 0;
} }

View File

@ -1,33 +1,83 @@
package fr.jcs.bigalarm.blocks; package fr.jcs.bigalarm.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fr.jcs.bigalarm.BigAlarm;
import fr.jcs.bigalarm.BigAlarmRefs; import fr.jcs.bigalarm.BigAlarmRefs;
import fr.jcs.bigalarm.tileentitys.TileEntityAlarm;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
public class AlarmBlock extends BlockContainer { public class AlarmBlock extends BlockContainer {
private IIcon iconAlarm;
public AlarmBlock() { public AlarmBlock() {
super(Material.iron); super(Material.iron);
this.setHardness(5.0F); setHardness(5.0F);
this.setResistance(4.0F); setResistance(20.0F);
this.setStepSound(soundTypeMetal); this.setStepSound(soundTypeMetal);
this.setUnlocalizedName(BigAlarmRefs.MOD_ID + ":alarmBlock"); this.setUnlocalizedName(BigAlarmRefs.MOD_ID + ":alarmBlock");
this.setTextureName(BigAlarmRefs.MOD_ID + ":alarmBlock/front"); this.setTextureName(BigAlarmRefs.MOD_ID + ":default");
this.setCreativeTab(CreativeTabs.tabDecorations); this.setCreativeTab(CreativeTabs.tabDecorations);
this.setLightOpacity(15);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) { //Method name different but is registerBlockIcons()
this.blockIcon = iconRegister.registerIcon(BigAlarmRefs.MOD_ID + ":alarmBlock/side");
this.iconAlarm = iconRegister.registerIcon(BigAlarmRefs.MOD_ID + ":alarmBlock/top");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
/*if (side == 1) { //Simplified sentence below
return this.iconAlarm;
} else {
return this.blockIcon;
}*/
return side == 1 ? this.iconAlarm : this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
return side == 1 ? this.iconAlarm : this.blockIcon;
} }
@Override
public void breakBlock(World worldIn, int x, int y, int z, Block blockBroken, int meta) {
super.breakBlock(worldIn, x, y, z, blockBroken, meta);
}
@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
if (!worldIn.isRemote) {
BigAlarm.proxy.openGui(BigAlarmRefs.GUIID_AlarmBlock,worldIn.getTileEntity(x, y, z));
}
return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ);
}
@Override @Override
public boolean isFullBlock() public boolean isFullBlock()
{ {
return false; return true;
} }
@Override @Override
public boolean isBlockNormalCube() { public boolean isBlockNormalCube() {
return false; return true;
} }
@Override @Override
@ -42,7 +92,7 @@ public class AlarmBlock extends BlockContainer {
@Override @Override
public TileEntity createNewTileEntity(World worldIn, int meta) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return null; return new TileEntityAlarm();
} }
} }

View File

@ -0,0 +1,91 @@
package fr.jcs.bigalarm.gui;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import fr.jcs.bigalarm.tileentitys.TileEntityAlarm;
import fr.jcs.bigalarm.utils.GuiHelper;
import fr.jcs.bigalarm.utils.ResourceHandler;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
public class GuiAlarmBlock extends GuiScreen{
private TileEntityAlarm tile;
public GuiAlarmBlock(TileEntityAlarm alarm) {
this.tile = alarm;
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
@Override
public void initGui() {
int guiLeft = (width / 2) - (197 / 2);
int guiTop = (height / 2) - (88 / 2);
buttonList.clear();
buttonList.add(new GuiTextureButton(0, guiLeft + 20, guiTop + 20, 0, 108, 18, 18, ""));
buttonList.add(new GuiTextureButton(1, guiLeft + 159, guiTop + 20, 0, 54, 18, 18, ""));
buttonList.add(new GuiTextureButton(2, guiLeft + 20, guiTop + 50, 0, 108, 18, 18, ""));
buttonList.add(new GuiTextureButton(3, guiLeft + 159, guiTop + 50, 0, 54, 18, 18, ""));
/*
if (tile.flowOverridden) return;
buttonList.add(new GuiTextureButton(0, guiLeft + 20, guiTop + 20, 0, 108, 18, 18, ""));
buttonList.add(new GuiTextureButton(1, guiLeft + 159, guiTop + 20, 0, 54, 18, 18, ""));
buttonList.add(new GuiTextureButton(2, guiLeft + 20, guiTop + 50, 0, 108, 18, 18, ""));
buttonList.add(new GuiTextureButton(3, guiLeft + 159, guiTop + 50, 0, 54, 18, 18, ""));
*/
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
int guiLeft = (width / 2) - (197 / 2);
int guiCrt = (width / 2);
int guiTop = (height / 2) - (88 / 2);
drawDefaultBackground();
ResourceHandler.bindResource("textures/gui/configPanel.png");
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 197, 88);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.bigalarm.alarmBlock.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.bigalarm.alarmBlock.name")) / 2), guiTop + 5, 0x2c2c2c);
ResourceHandler.bindResource("textures/gui/widgets.png");
super.drawScreen(mouseX, mouseY, partialTicks);
List<String> hoverText = new ArrayList<String>();
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
if (GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, mouseX, mouseY)) {
//hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl));
hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name"));
}
if (GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, mouseX, mouseY)) {
//hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(1, shift, ctrl));
hoverText.add(StatCollector.translateToLocal("gui.de.increment.name"));
}
if (GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, mouseX, mouseY)) {
//hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(0, shift, ctrl));
hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name"));
}
if (GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, mouseX, mouseY)) {
//hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(0, shift, ctrl));
hoverText.add(StatCollector.translateToLocal("gui.de.increment.name"));
}
if (!hoverText.isEmpty()) {
hoverText.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("gui.de.pressOrScroll.name"));
//drawHoveringText(hoverText, x - (x < width / 2 ? fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl)) + 25 : 0), y, fontRendererObj);
drawHoveringText(hoverText, mouseX - (mouseX < width / 2 ? fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.decrement.name")) + 25 : 0), mouseY, fontRendererObj);
}
}
}

View File

@ -0,0 +1,46 @@
package fr.jcs.bigalarm.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
public class GuiTextureButton extends GuiButton {
public int textureXPos;
public int textureYPos;
public GuiTextureButton(int id, int xPos, int yPos, int textureXPos, int textureYPos, int xSise, int ySise, String text) {
super(id, xPos, yPos, xSise, ySise, text);
this.textureXPos = textureXPos;
this.textureYPos = textureYPos;
}
@Override
public void drawButton(Minecraft mc, int x, int y) {
if (this.visible) {
FontRenderer fontrenderer = mc.fontRendererObj;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
int k = this.getHoverState(this.hovered);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, textureXPos, textureYPos + k * height, this.width, this.height);
this.mouseDragged(mc, x, y);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.hovered) {
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
}
}
}

View File

@ -3,8 +3,13 @@ package fr.jcs.bigalarm.proxy;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import fr.jcs.bigalarm.BigAlarmRefs;
import fr.jcs.bigalarm.gui.GuiAlarmBlock;
import fr.jcs.bigalarm.tileentitys.TileEntityAlarm;
import net.minecraft.client.Minecraft;
public class ClientProxy extends CommonProxy { public class ClientProxy extends CommonProxy {
/*
@Override @Override
public void registerTileEntities() { public void registerTileEntities() {
//TileEntityIC2ThermoRenderer renderThermalMonitor = new TileEntityIC2ThermoRenderer(); //TileEntityIC2ThermoRenderer renderThermalMonitor = new TileEntityIC2ThermoRenderer();
@ -12,4 +17,14 @@ public class ClientProxy extends CommonProxy {
//ClientRegistry.registerTileEntity(shedar.mods.ic2.nuclearcontrol.tileentities.TileEntityThermo.class, "IC2Thermo", renderThermalMonitor); //ClientRegistry.registerTileEntity(shedar.mods.ic2.nuclearcontrol.tileentities.TileEntityThermo.class, "IC2Thermo", renderThermalMonitor);
//GameRegistry.registerTileEntity(shedar.mods.ic2.nuclearcontrol.tileentities.TileEntityHowlerAlarm.class, "IC2HowlerAlarm"); //GameRegistry.registerTileEntity(shedar.mods.ic2.nuclearcontrol.tileentities.TileEntityHowlerAlarm.class, "IC2HowlerAlarm");
} }
*/
@Override
public void openGui(int id, Object arg) {
switch (id) {
case BigAlarmRefs.GUIID_AlarmBlock:
Minecraft.getMinecraft().displayGuiScreen(new GuiAlarmBlock((TileEntityAlarm)arg));
break;
}
}
} }

View File

@ -1,9 +1,17 @@
package fr.jcs.bigalarm.proxy; package fr.jcs.bigalarm.proxy;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import fr.jcs.bigalarm.BigAlarmRefs;
import fr.jcs.bigalarm.tileentitys.TileEntityAlarm;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CommonProxy { public class CommonProxy {
public void registerTileEntities() { public void registerTileEntities() {
//GameRegistry.registerTileEntity(TileEntityThermo.class, "IC2Thermo"); GameRegistry.registerTileEntity(TileEntityAlarm.class, BigAlarmRefs.MOD_ID + "TileAlarmBlock");
} }
public void openGui(int id, Object arg) {}
} }

View File

@ -0,0 +1,79 @@
package fr.jcs.bigalarm.tileentitys;
import cpw.mods.fml.common.FMLCommonHandler;
import fr.jcs.bigalarm.BigAlarmRefs;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityAlarm extends TileEntity {
private static final String DEFAULT_SOUND_NAME = "default";
private static final float BASE_SOUND_RANGE = 16F;
private static final String SOUND_PREFIX = BigAlarmRefs.MOD_ID + ":alarm-";
public int range;
private int prevRange;
public String soundName;
private String prevSoundName;
private int updateTicker;
protected int tickRate;
private TileEntitySound sound;
public TileEntityAlarm() {
soundName = "";
//range = IC2NuclearControl.instance.alarmRange;
range = 0;
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
sound = new TileEntitySound();
}
}
public int getRange() {
return range;
}
public void setRange(int r) {
range = r;
if (prevRange != r) {
//IC2.network.get().updateTileEntityField(this, "range");
}
prevRange = range;
}
public String getSoundName() {
return soundName;
}
public void setSoundName(String name) {
soundName = name;
if (prevSoundName != name){
//IC2.network.get().updateTileEntityField(this, "soundName");
}
prevSoundName = name;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (nbttagcompound.hasKey("soundName")) {
prevSoundName = soundName = nbttagcompound.getString("soundName");
prevRange = range = nbttagcompound.getInteger("range");
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setString("soundName", soundName);
nbttagcompound.setInteger("range", range);
}
/*
public String getToolTip(int selector, boolean shift, boolean ctrl) {
int i = selector == 0 ? flowRSLow / 100000 * 10000 : flowRSHigh / 100000 * 10000;
int b1 = shift ? ctrl ? 10000 + i : 1000 : ctrl ? 5 : 50;
int b2 = shift ? ctrl ? 1000 : 100 : ctrl ? 1 : 10;
return b1 + "/" + b2 + " RF/t";
}
*/
}

View File

@ -0,0 +1,32 @@
package fr.jcs.bigalarm.tileentitys;
import fr.jcs.bigalarm.utils.SoundHelper;
import net.minecraft.client.audio.PositionedSoundRecord;
public class TileEntitySound {
private PositionedSoundRecord sound;
public TileEntitySound() {
}
public void stopAlarm() {
if (sound != null) {
SoundHelper.stopAlarm(sound);
sound = null;
}
}
public void playAlarm(double x, double y, double z, String soundName,
float range, boolean skipCheck) {
if (sound == null || skipCheck) {
sound = SoundHelper.playAlarm(x, y, z, soundName, range);
}
}
public boolean isPlaying() {
if (sound == null) {
return false;
}
return SoundHelper.isPlaying(sound);
}
}

View File

@ -0,0 +1,139 @@
package fr.jcs.bigalarm.utils;
import java.util.Iterator;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
public class GuiHelper {
public static final double PXL128 = 0.0078125;
public static final double PXL256 = 0.00390625;
public static boolean isInRect(int x, int y, int xSize, int ySize, int mouseX, int mouseY){
return ((mouseX >= x && mouseX <= x+xSize) && (mouseY >= y && mouseY <= y+ySize));
}
public static void drawTexturedRect(int x, int y, int u, int v, int width, int height){
drawTexturedRect(x, y, width, height, u, v, width, height, 0, PXL256);
}
public static void drawTexturedRect(double x, double y, double width, double height, int u, int v, int uSize, int vSize, double zLevel, double pxl){
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + height, zLevel, u * pxl, (v + vSize) * pxl);
tessellator.addVertexWithUV(x + width, y + height, zLevel, (u + uSize) * pxl, (v + vSize) * pxl);
tessellator.addVertexWithUV(x + width, y, zLevel, (u + uSize) * pxl, v * pxl);
tessellator.addVertexWithUV(x, y, zLevel, u * pxl, v * pxl);
tessellator.draw();
}
public static void drawHoveringText(List list, int x, int y, FontRenderer font, float fade, double scale, int guiWidth, int guiHeight) {
if (!list.isEmpty())
{
GL11.glPushMatrix();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glScaled(scale, scale, 1);
x = (int)(x/scale);
y = (int)(y/scale);
int k = 0;
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
String s = (String)iterator.next();
int l = font.getStringWidth(s);
if (l > k)
{
k = l;
}
}
int adjX = x + 12;
int adjY = y - 12;
int i1 = 8;
if (list.size() > 1)
{
i1 += 2 + (list.size() - 1) * 10;
}
if (adjX + k > (int)(guiWidth/scale))
{
adjX -= 28 + k;
}
if (adjY + i1 + 6 > (int)(guiHeight/scale))
{
adjY = (int)(guiHeight/scale) - i1 - 6;
}
int j1 = -267386864;
drawGradientRect(adjX - 3, adjY - 4, adjX + k + 3, adjY - 3, j1, j1, fade, scale);
drawGradientRect(adjX - 3, adjY + i1 + 3, adjX + k + 3, adjY + i1 + 4, j1, j1, fade, scale);
drawGradientRect(adjX - 3, adjY - 3, adjX + k + 3, adjY + i1 + 3, j1, j1, fade, scale);
drawGradientRect(adjX - 4, adjY - 3, adjX - 3, adjY + i1 + 3, j1, j1, fade, scale);
drawGradientRect(adjX + k + 3, adjY - 3, adjX + k + 4, adjY + i1 + 3, j1, j1, fade, scale);
int k1 = 1347420415;
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
drawGradientRect(adjX - 3, adjY - 3 + 1, adjX - 3 + 1, adjY + i1 + 3 - 1, k1, l1, fade, scale);
drawGradientRect(adjX + k + 2, adjY - 3 + 1, adjX + k + 3, adjY + i1 + 3 - 1, k1, l1, fade, scale);
drawGradientRect(adjX - 3, adjY - 3, adjX + k + 3, adjY - 3 + 1, k1, k1, fade, scale);
drawGradientRect(adjX - 3, adjY + i1 + 2, adjX + k + 3, adjY + i1 + 3, l1, l1, fade, scale);
for (int i2 = 0; i2 < list.size(); ++i2)
{
String s1 = (String)list.get(i2);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
font.drawStringWithShadow(s1, adjX, adjY, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF);
adjY += 10;
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
public static void drawGradientRect(int x1, int y1, int x2, int y2, int colour1, int colour2, float fade, double scale) {
float f = ((colour1 >> 24 & 255) / 255.0F) * fade;
float f1 = (float)(colour1 >> 16 & 255) / 255.0F;
float f2 = (float)(colour1 >> 8 & 255) / 255.0F;
float f3 = (float)(colour1 & 255) / 255.0F;
float f4 = ((colour2 >> 24 & 255) / 255.0F) * fade;
float f5 = (float)(colour2 >> 16 & 255) / 255.0F;
float f6 = (float)(colour2 >> 8 & 255) / 255.0F;
float f7 = (float)(colour2 & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f1, f2, f3, f);
tessellator.addVertex((double)x2, (double)y1, 300D);
tessellator.addVertex((double)x1, (double)y1, 300D);
tessellator.setColorRGBA_F(f5, f6, f7, f4);
tessellator.addVertex((double)x1, (double)y2, 300D);
tessellator.addVertex((double)x2, (double)y2, 300D);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
}

View File

@ -0,0 +1,24 @@
package fr.jcs.bigalarm.utils;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import fr.jcs.bigalarm.BigAlarmRefs;
public class LogHelper {
public static void log(Level logLevel, Object object) {
FMLLog.log(BigAlarmRefs.MOD_ID, logLevel, String.valueOf(object), new Object[0]);
}
public static void error(Object object) {
log(Level.ERROR, object);
}
public static void info(Object object) {
log(Level.INFO, object);
}
public static void warn(Object object) {
log(Level.WARN, object);
}
}

View File

@ -0,0 +1,27 @@
package fr.jcs.bigalarm.utils;
import java.util.HashMap;
import java.util.Map;
import fr.jcs.bigalarm.BigAlarmRefs;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class ResourceHandler {
public static ResourceHandler instance = new ResourceHandler();
private static Map<String, ResourceLocation> cachedResources = new HashMap<String, ResourceLocation>();
public static ResourceLocation getResource(String rs) {
if (!cachedResources.containsKey(rs))
cachedResources.put(rs, new ResourceLocation(BigAlarmRefs.RESOURCESPREFIX + rs));
return cachedResources.get(rs);
}
public static void bindTexture(ResourceLocation texture) {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
}
public static void bindResource(String rs) {
bindTexture(ResourceHandler.getResource(rs));
}
}

View File

@ -0,0 +1,44 @@
package fr.jcs.bigalarm.utils;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class SoundHelper {
private static final float DEFAULT_RANGE = 16F;
private static void playSound(PositionedSoundRecord sound) {
Minecraft.getMinecraft().getSoundHandler().playSound(sound);
}
public static PositionedSoundRecord playAlarm(double x, double y, double z,
String name, float volume) {
float range = DEFAULT_RANGE;
if (volume > 1.0F) {
range *= volume;
}
Entity person = FMLClientHandler.instance().getClient().renderViewEntity;
if (person != null && volume > 0
&& person.getDistanceSq(x, y, z) < range * range) {
PositionedSoundRecord sound = new PositionedSoundRecord(
new ResourceLocation(name), volume, 1.0F, (float) x,
(float) y, (float) z);
playSound(sound);
return sound;
}
return null;
}
public static boolean isPlaying(PositionedSoundRecord sound) {
return Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(sound);
}
public static void stopAlarm(PositionedSoundRecord sound) {
Minecraft.getMinecraft().getSoundHandler().stopSound(sound);
}
}

View File

@ -1 +1,3 @@
tile.bigalarm:alarmBlock.name=Alarm tile.bigalarm:alarmBlock.name=Alarm
gui.bigalarm.alarmBlock.name=Configuration Panel

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB