Skip to content

Commit

Permalink
Update for 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
GotoLink committed Apr 20, 2015
1 parent 27b06fd commit b3ca5b7
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 233 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -27,8 +27,9 @@ targetCompatibility = 1.6
version = "1.0"
group = "info.satscape.alarmcraft"
minecraft {
version = "1.8-11.14.1.1350"
runDir = "eclipse"
version = "1.7.10-10.13.2.1230"
mappings = "snapshot_20150401"
}
archivesBaseName = "Alarmcraft"
//Set the workspace
Expand Down
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "satscapealarmcraft:alarm" }
}
}
2 changes: 1 addition & 1 deletion resources/assets/satscapealarmcraft/lang/en_US.lang
@@ -1,5 +1,5 @@

tile.SatscapeAlarm.name=Alarm box
tile.alarm.name=Alarm box
gui.alarm.fulltext=Press the button below to cycle through the different types of alarms available. When you've found the one you want, click the 'Done' button at the bottom. Supply a redstone pulse (on/off signal) to any side of the box to sound the alarm.
gui.alarm.name=Alarm %s
gui.alarm.test=Test
Expand Down
20 changes: 20 additions & 0 deletions resources/assets/satscapealarmcraft/models/block/alarm.json
@@ -0,0 +1,20 @@
{
"textures": {
"particle": "satscapealarmcraft:blocks/alarmside",
"side": "satscapealarmcraft:blocks/alarmside",
"top": "satscapealarmcraft:blocks/alarmtop"
},
"elements": [
{ "from": [ 3, 0, 3 ],
"to": [ 13, 4, 13 ],
"faces": {
"down": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
"up": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
"north": { "uv": [ 2, 11, 14, 16 ], "texture": "#side" },
"south": { "uv": [ 2, 11, 14, 16 ], "texture": "#side" },
"west": { "uv": [ 2, 11, 14, 16 ], "texture": "#side" },
"east": { "uv": [ 2, 11, 14, 16 ], "texture": "#side" }
}
}
]
}
10 changes: 10 additions & 0 deletions resources/assets/satscapealarmcraft/models/item/SatscapeAlarm.json
@@ -0,0 +1,10 @@
{
"parent": "satscapealarmcraft:block/alarm",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}
25 changes: 23 additions & 2 deletions src/alarmcraft/client/ClientProxy.java
Expand Up @@ -2,9 +2,17 @@

import alarmcraft.common.AlarmSettings;
import alarmcraft.common.CommonProxy;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

import java.util.Map;

public final class ClientProxy extends CommonProxy {

Expand All @@ -14,7 +22,20 @@ public void openAlarmGui(AlarmSettings alarm, EntityPlayer player) {
}

@Override
public EntityPlayer getPlayer(MessageContext ctx){
public EntityPlayer getPlayer(MessageContext ctx) {
return Minecraft.getMinecraft().thePlayer;
}

@Override
public void registerBlock(final Block block, final String name) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(name, "inventory"));
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().registerBlockWithStateMapper(block, new IStateMapper(){
private final Map internal = Maps.newLinkedHashMap();
@Override
public Map putStateModelLocations(Block block) {
internal.put(block.getDefaultState(), new ModelResourceLocation(name, "normal"));
return internal;
}
});
}
}
206 changes: 103 additions & 103 deletions src/alarmcraft/client/GuiAlarmSettings.java
Expand Up @@ -2,126 +2,126 @@

import alarmcraft.common.AlarmSettings;
import alarmcraft.common.PacketHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public final class GuiAlarmSettings extends GuiScreen {
private static final ResourceLocation myBackgroundTexture = new ResourceLocation("satscapealarmcraft","textures/gui/guiBack.png");
private EntityPlayer thePlayer;
private AlarmSettings alarm;
private int mouseCount=0;
private int tempMeta=0;
private String alertText="";

public GuiAlarmSettings(AlarmSettings alarm,EntityPlayer player) {
this.alarm=alarm;
this.thePlayer=player;
}
private static final ResourceLocation myBackgroundTexture = new ResourceLocation("satscapealarmcraft", "textures/gui/guiBack.png");
private EntityPlayer thePlayer;
private AlarmSettings alarm;
private int mouseCount = 0;
private int tempMeta = 0;
private String alertText = "";

public GuiAlarmSettings(AlarmSettings alarm, EntityPlayer player) {
this.alarm = alarm;
this.thePlayer = player;
}

@Override
public boolean doesGuiPauseGame() {
return false;
}

@Override
public boolean doesGuiPauseGame() {
return false;
}

@Override
public void initGui() {
showPage();
Mouse.setGrabbed(false);
}

@Override
public void drawScreen(int i, int j, float f) {

if (mouseCount<10) {
mouseCount++;
Mouse.setGrabbed(false);
}

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(myBackgroundTexture);

int posX = (this.width - 256) / 2;
drawTexturedModalRect(posX, 5, 0, 0, 256, 230);

drawCenteredString(fontRendererObj, "Alarmcraft", width / 2, 10, 0xFF1010);
public void initGui() {
showPage();
Mouse.setGrabbed(false);
}

@Override
public void drawScreen(int i, int j, float f) {

if (mouseCount < 10) {
mouseCount++;
Mouse.setGrabbed(false);
}

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(myBackgroundTexture);

int posX = (this.width - 256) / 2;
drawTexturedModalRect(posX, 5, 0, 0, 256, 230);

drawCenteredString(fontRendererObj, "Alarmcraft", width / 2, 10, 0xFF1010);
int textBorder = 5;
fontRendererObj.drawSplitString(I18n.format("gui.alarm.fulltext"), posX+textBorder, 30, 256-textBorder*2, 0xFFFFFF);
drawCenteredString(fontRendererObj, I18n.format(alertText), width/2, 150, 0x00FF00);

super.drawScreen(i, j, f);
}

private void showPage() {
buttonList.clear();
buttonList.add(new GuiButton(0, this.width/2-25, 210, 50, 20, I18n.format("gui.done")));

tempMeta=alarm.theType;
if (tempMeta<26) {
char ch=(char) (65+tempMeta);
buttonList.add(new GuiButton(1, this.width/2-50,100,100,20,I18n.format("gui.alarm.name", ch)));
}else{
buttonList.add(new GuiButton(1, this.width/2-50,100,100,20,I18n.format("gui.alert.name")));
fontRendererObj.drawSplitString(I18n.format("gui.alarm.fulltext"), posX + textBorder, 30, 256 - textBorder * 2, 0xFFFFFF);
drawCenteredString(fontRendererObj, I18n.format(alertText), width / 2, 150, 0x00FF00);

super.drawScreen(i, j, f);
}

private void showPage() {
buttonList.clear();
buttonList.add(new GuiButton(0, this.width / 2 - 25, 210, 50, 20, I18n.format("gui.done")));

tempMeta = alarm.theType;
if (tempMeta < 26) {
char ch = (char) (65 + tempMeta);
buttonList.add(new GuiButton(1, this.width / 2 - 50, 100, 100, 20, I18n.format("gui.alarm.name", ch)));
} else {
buttonList.add(new GuiButton(1, this.width / 2 - 50, 100, 100, 20, I18n.format("gui.alert.name")));
}
buttonList.add(new GuiButton(2, this.width / 2 - 25, 120, 50, 20, I18n.format("gui.alarm.test")));
}

@Override
protected void actionPerformed(GuiButton guibutton) {
if (!guibutton.enabled) {
return;
}
buttonList.add(new GuiButton(2, this.width/2-25,120,50,20,I18n.format("gui.alarm.test")));
}

@Override
protected void actionPerformed(GuiButton guibutton) {
if (!guibutton.enabled) {
return;
}
if (guibutton.id == 0) // SET alarm button
{
if (guibutton.id == 0) // SET alarm button
{
this.alarm.theType = tempMeta;
this.alarm.isPowered = false;
this.alarm.playersUsername = "";
PacketHandler.sendPacketToServer(this.alarm, "update");
PacketHandler.sendPacketToServer(this.alarm, "update");

thePlayer.worldObj.playSoundAtEntity(thePlayer, "satscapealarmcraft:carlock", 1f, 1f);
mc.currentScreen = null;
mc.setIngameFocus();
} else if (guibutton.id == 1) { //change alarm type button
tempMeta++;
if (tempMeta>12 && tempMeta<26) {
tempMeta=26;
} else if (tempMeta>26) {
tempMeta=0;
}
if (tempMeta<26) {
char ch=(char) (65+tempMeta);
guibutton.displayString=I18n.format("gui.alarm.name",ch);
alertText="";
} else {
guibutton.displayString=I18n.format("gui.alert.name");
alertText="gui.alert.desc";
}
} else if (guibutton.id == 2) { //test the alarm button
if (tempMeta <26) {
char ch=(char) (65+tempMeta);
thePlayer.worldObj.playSoundAtEntity(thePlayer, "satscapealarmcraft:alarm" + ch, 1f, 1f);
alertText="";
} else {
alertText="gui.alert.test";
}
}
}

@Override
protected void keyTyped(char c, int i) {
if (i == 1) { // escape and dont save
mc.currentScreen = null;
mc.setIngameFocus();
}
}

mc.currentScreen = null;
mc.setIngameFocus();

} else if (guibutton.id == 1) { //change alarm type button
tempMeta++;
if (tempMeta > 12 && tempMeta < 26) {
tempMeta = 26;
} else if (tempMeta > 26) {
tempMeta = 0;
}
if (tempMeta < 26) {
char ch = (char) (65 + tempMeta);
guibutton.displayString = I18n.format("gui.alarm.name", ch);
alertText = "";
} else {
guibutton.displayString = I18n.format("gui.alert.name");
alertText = "gui.alert.desc";
}

} else if (guibutton.id == 2) { //test the alarm button
if (tempMeta < 26) {
char ch = (char) (65 + tempMeta);
thePlayer.worldObj.playSoundAtEntity(thePlayer, "satscapealarmcraft:alarm" + ch, 1f, 1f);
alertText = "";
} else {
alertText = "gui.alert.test";
}
}
}

@Override
protected void keyTyped(char c, int i) {
if (i == 1) { // escape and dont save
mc.currentScreen = null;
mc.setIngameFocus();
}
}
}

0 comments on commit b3ca5b7

Please sign in to comment.