Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
added solder armor
Browse files Browse the repository at this point in the history
  • Loading branch information
roryclaasen committed Jul 24, 2017
1 parent 0a10c58 commit 4289acf
Show file tree
Hide file tree
Showing 21 changed files with 213 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void sync() {
}

public void sendGUIUpdate() {
super.sync();
sync();

PacketDispatcher.sendToAll(new SyncRenamerInfo(xCoord, yCoord, zCoord, active, tickSinceLastRename));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.ArrayList;
import java.util.List;

import cofh.lib.gui.slot.SlotSpecificItem;
import me.roryclaasen.rorysmod.block.tile.TileEntityRifleTable;
import me.roryclaasen.rorysmod.container.slot.RestrictedSlot;
import me.roryclaasen.rorysmod.container.slot.RifleUpgradeSlot;
import me.roryclaasen.rorysmod.core.RorysMod;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -40,8 +40,8 @@ public ContainerRifleTable(InventoryPlayer inventoryPlayer, TileEntityRifleTable
rifles.add(new ItemStack(RorysMod.items.rifle4));
rifles.add(new ItemStack(RorysMod.items.rifle5));

this.addSlotToContainer(new RestrictedSlot(tileEntity, 0, 8, 8).setAllowedItemStack(rifles));
this.addSlotToContainer(new RestrictedSlot(tileEntity, 1, 134, 7).setAllowedItemStack(new ItemStack(RorysMod.items.rifleUpgrade, 1, 3)).setLimit(1).useTags());
this.addSlotToContainer(new SlotSpecificItem(tileEntity, 0, 8, 8, new ItemStack(RorysMod.items.rifle1)).setSlotStackLimit(1));
this.addSlotToContainer(new SlotSpecificItem(tileEntity, 1, 134, 7, new ItemStack(RorysMod.items.rifleUpgrade, 1, 3)).setSlotStackLimit(1));

for (int y = 0; y < 3; y++) {
for (int x = 0; x < 2; x++) {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/core/RorysGlobal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2017 Rory Claasen
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.roryclaasen.rorysmod.core;

import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;

public class RorysGlobal {

private RorysGlobal() {}

public static final ArmorMaterial SOLDER_ARMOR = EnumHelper.addArmorMaterial("solder", 12, new int[] { 2, 5, 3, 1 }, 15);

}
19 changes: 19 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/core/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import me.roryclaasen.rorysmod.item.ItemIngot;
import me.roryclaasen.rorysmod.item.ItemPlate;
import me.roryclaasen.rorysmod.item.ItemRifleUpgrade;
import me.roryclaasen.rorysmod.item.ItemSolderArmor;
import me.roryclaasen.rorysmod.item.base.ItemBase;
import me.roryclaasen.rorysmod.item.tools.ItemRifle;
import me.roryclaasen.rorysmod.item.tools.ItemSolderingIron;
Expand All @@ -47,6 +48,8 @@ public class ModItems implements ModInterface {
public Item solderingIron;
public Item solderDust, solderIngot, solderPlate, solderWire, solderCoil;

public Item solderHelm, solderChest, solderLegs, solderBoots;

@Override
public void preInit(FMLPreInitializationEvent event) {
steelIngot = new ItemIngot("ingotSteel");
Expand Down Expand Up @@ -76,6 +79,11 @@ public void preInit(FMLPreInitializationEvent event) {
solderPlate = new ItemPlate("plateSolder");
solderWire = new ItemBase("wireSolder");
solderCoil = new ItemCoil("coilSolder");

solderHelm = new ItemSolderArmor("solder_helmet", 0);
solderChest = new ItemSolderArmor("solder_chestplate", 1);
solderLegs = new ItemSolderArmor("solder_leggings", 2);
solderBoots = new ItemSolderArmor("solder_boots", 3);
}

public void register(FMLPreInitializationEvent event) {
Expand Down Expand Up @@ -108,6 +116,10 @@ public void register(FMLPreInitializationEvent event) {
Register.registerItem(solderPlate);
Register.registerItem(solderWire);
Register.registerItem(solderCoil);
Register.registerItem(solderHelm);
Register.registerItem(solderChest);
Register.registerItem(solderLegs);
Register.registerItem(solderBoots);

Register.registerDictionary("ingotSteel", steelIngot);
Register.registerDictionary("dustSteel", steelDust);
Expand Down Expand Up @@ -209,6 +221,13 @@ public void init(FMLInitializationEvent event) {

Recipes.metalformerCutting.addRecipe(new RecipeInputItemStack(new ItemStack(solderCoil)), null, new ItemStack(solderWire, 8));
Register.addShapelessRecipie(new ItemStack(solderWire, 8), "coilSolder", wireCutters);

// Solder Armor
Register.addShapedRecipie(new ItemStack(solderHelm), new Object[] { "sss", "s s", 's', "ingotSolder" });
Register.addShapedRecipie(new ItemStack(solderChest), new Object[] { "s s", "sss", "sss", 's', "ingotSolder" });
Register.addShapedRecipie(new ItemStack(solderLegs), new Object[] { "sss", "s s", "s s", 's', "ingotSolder" });
Register.addShapedRecipie(new ItemStack(solderBoots), new Object[] { "s s", "s s", 's', "ingotSolder" });

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onPlayerSleepInBedEvent(PlayerSleepInBedEvent event) throws IllegalA
event.result = EntityPlayer.EnumStatus.NOT_SAFE;
return;
} else {
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.rorysmod.sleeping.mobsclose")));
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.rorysmod.sleeping.mobs")));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void initGui() {

this.tileEntity.sync();

elements.add(new ElementEnergyStored(this, 8, 17, tileEntity.getEnergy()));
elements.add(getEnergyStoredElement());

renameField = new ElementTextField(this, 43, 20, 103, 12);
renameField.setText(this.tileEntity.getCustomName());
Expand Down Expand Up @@ -86,5 +86,10 @@ protected void mouseClicked(int paramInt1, int paramInt2, int paramInt3) {
protected void updateElementInformation() {
super.updateElementInformation();
this.progress.setQuantity(this.tileEntity.getScaledProgress(24));
this.elements.set(0, getEnergyStoredElement());
}

private ElementEnergyStored getEnergyStoredElement() {
return new ElementEnergyStored(this, 8, 17, this.tileEntity.getEnergy());
}
}
64 changes: 19 additions & 45 deletions src/main/java/me/roryclaasen/rorysmod/gui/GuiPoweredChest.java
Original file line number Diff line number Diff line change
@@ -1,60 +1,34 @@
/*
Copyright 2016-2017 Rory Claasen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* Copyright 2016-2017 Rory Claasen
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.roryclaasen.rorysmod.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import cofh.lib.gui.GuiBase;
import me.roryclaasen.rorysmod.block.tile.TileEntityPoweredChest;
import me.roryclaasen.rorysmod.container.ContainerPoweredChest;
import me.roryclaasen.rorysmod.core.RorysMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

public class GuiPoweredChest extends GuiContainer {

private ResourceLocation texture = new ResourceLocation(RorysMod.MODID, "textures/gui/chest.png");

private InventoryPlayer inventory;
private TileEntityPoweredChest te;
public class GuiPoweredChest extends GuiBase {

public GuiPoweredChest(TileEntityPoweredChest te, EntityPlayer player) {
super(new ContainerPoweredChest(te, player));
inventory = player.inventory;
this.te = te;
}

@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

int x = (width - xSize) / 2;
int y = (height - ySize) / 2;

drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
super(new ContainerPoweredChest(te, player), new ResourceLocation(RorysMod.MODID, "textures/gui/chest.png"));
}

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(I18n.format(te.getInventoryName()), 8, 6, 4210752, false);
fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752);
public void initGui() {
super.initGui();
this.name = StatCollector.translateToLocal(RorysMod.GUIS.CHEST_POWERED.getName() + ".title");
}
}
80 changes: 37 additions & 43 deletions src/main/java/me/roryclaasen/rorysmod/gui/GuiRifleTable.java
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
/*
Copyright 2016-2017 Rory Claasen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* Copyright 2016-2017 Rory Claasen
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.roryclaasen.rorysmod.gui;

import java.awt.Color;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;

import cofh.lib.gui.GuiBase;
import cpw.mods.fml.client.config.GuiSlider;
import me.roryclaasen.rorysmod.block.tile.TileEntityRifleTable;
import me.roryclaasen.rorysmod.container.ContainerRifleTable;
import me.roryclaasen.rorysmod.core.RorysMod;
import me.roryclaasen.rorysmod.core.Settings;
import me.roryclaasen.rorysmod.item.tools.ItemRifle;
import me.roryclaasen.rorysmod.util.ColorUtils;
import me.roryclaasen.rorysmod.util.NBTLaser;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.config.GuiSlider;

public class GuiRifleTable extends GuiContainer {
public class GuiRifleTable extends GuiBase {

private TileEntityRifleTable tileEntity;

private ResourceLocation empty = new ResourceLocation(RorysMod.MODID, "textures/gui/table-empty.png");
private ResourceLocation table = new ResourceLocation(RorysMod.MODID, "textures/gui/table.png");
private static ResourceLocation empty = new ResourceLocation(RorysMod.MODID, "textures/gui/table-empty.png");
private static ResourceLocation table = new ResourceLocation(RorysMod.MODID, "textures/gui/table.png");

private GuiSlider colorR, colorG, colorB;
private GuiButton save;

public GuiRifleTable(InventoryPlayer inventoryPlayer, TileEntityRifleTable tileEntity) {
super(new ContainerRifleTable(inventoryPlayer, tileEntity));
super(new ContainerRifleTable(inventoryPlayer, tileEntity), empty);
this.tileEntity = tileEntity;
this.tileEntity.setGuiRifleTable(this);

Expand All @@ -65,11 +61,15 @@ public void initGui() {
buttonList.add(colorG);
buttonList.add(colorB);
buttonList.add(save);

this.name = StatCollector.translateToLocal(RorysMod.GUIS.RILE_TABLE.getName() + ".title");
this.drawInventory = false;
this.drawTitle = false;
}

@Override
protected void drawGuiContainerForegroundLayer(int param1, int param2) {
fontRendererObj.drawString(StatCollector.translateToLocal((RorysMod.GUIS.RILE_TABLE.getName() + ".title")), 30, 8, 4210752);
super.drawGuiContainerForegroundLayer(param1, param2);
if (slidersEnabled()) fontRendererObj.drawString((StatCollector.translateToLocal(RorysMod.GUIS.RILE_TABLE.getName() + ".color")), -colorR.width + 10, 10, ColorUtils.getIntFromColor(getColorFromSlider()));
if (tileEntity.hasLaser()) {
NBTLaser nbt = new NBTLaser(tileEntity.getLaser());
Expand All @@ -81,12 +81,7 @@ protected void drawGuiContainerForegroundLayer(int param1, int param2) {

@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(empty);
if (tileEntity.hasLaser()) this.mc.renderEngine.bindTexture(table);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
super.drawGuiContainerBackgroundLayer(par1, par2, par3);

if (Settings.showColorBox && slidersEnabled()) {
int id = ColorUtils.loadTextureFromColour(getColorFromSlider(), 64, 64);
Expand All @@ -95,10 +90,6 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
}
}

public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
}

@Override
public void updateScreen() {
int x = (width - xSize) / 2;
Expand All @@ -115,24 +106,27 @@ public void updateScreen() {
save.yPosition = colorB.yPosition + colorB.height + 10;

setSlidersEnabled(tileEntity.hasLens());

if (tileEntity.hasLaser()) this.texture = table;
else this.texture = empty;
super.updateScreen();
}

public void actionPerformed(GuiButton button) {
switch (button.id) {
case 1 :
case 1:
// tileEntity.setColor(getColorFromSlider());
break;
case 2 :
case 2:
// tileEntity.setColor(getColorFromSlider());
break;
case 3 :
case 3:
// tileEntity.setColor(getColorFromSlider());
break;
case 4 :
case 4:
tileEntity.setColor(getColorFromSlider());
break;
default :
default:
break;
}
}
Expand Down

0 comments on commit 4289acf

Please sign in to comment.