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

Commit

Permalink
Updated code, added some new things
Browse files Browse the repository at this point in the history
  • Loading branch information
roryclaasen committed Aug 28, 2017
1 parent 206868d commit 0ccd60a
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 7 deletions.
51 changes: 51 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/command/CommandBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.command;

import java.util.List;

import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;

public abstract class CommandBase extends net.minecraft.command.CommandBase {

protected final List<String> aliases;

public CommandBase(List<String> aliases) {
this.aliases = aliases;
}

public int compareTo(Object o) {
return super.compareTo((ICommand) o);
}

@Override
public int getRequiredPermissionLevel() {
return 0;
}

@Override
public abstract String getCommandName();

@Override
public abstract String getCommandUsage(ICommandSender sender);

@SuppressWarnings("rawtypes")
@Override
public List getCommandAliases() {
return this.aliases;
}

@Override
public abstract void processCommand(ICommandSender sender, String[] args);
}
39 changes: 39 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/command/CommandPing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.command;

import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;

public class CommandPing extends CommandBase {

public CommandPing() {
super(null);
}

@Override
public String getCommandName() {
return "ping";
}

@Override
public String getCommandUsage(ICommandSender sender) {
return "/ping";
}

@Override
public void processCommand(ICommandSender sender, String[] args) {
if (sender.getEntityWorld().isRemote) return;
sender.addChatMessage(new ChatComponentText("pong"));
}
}
19 changes: 17 additions & 2 deletions src/main/java/me/roryclaasen/rorysmod/core/RorysMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import me.roryclaasen.rorysmod.block.tile.TileEntityPoweredChest;
import me.roryclaasen.rorysmod.block.tile.TileEntityRenamer;
import me.roryclaasen.rorysmod.block.tile.TileEntityRifleTable;
import me.roryclaasen.rorysmod.core.init.ModAchievements;
import me.roryclaasen.rorysmod.core.init.ModBlocks;
import me.roryclaasen.rorysmod.core.init.ModCommands;
import me.roryclaasen.rorysmod.core.init.ModItems;
import me.roryclaasen.rorysmod.core.intergrations.MekanismPlugin;
import me.roryclaasen.rorysmod.core.network.PacketDispatcher;
Expand Down Expand Up @@ -77,6 +80,8 @@ public String getName() {

public static ModBlocks blocks;
public static ModItems items;
public static ModAchievements achievements;
private static ModCommands commands;

public static CreativeTabs creativeTab;

Expand All @@ -87,13 +92,15 @@ public String getName() {

blocks = new ModBlocks();
items = new ModItems();
achievements = new ModAchievements();
commands = new ModCommands();
}

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
instance = this;

versionCheker = new Version(RorysGlobal.VERSION);
versionCheker = new Version();

settings = new RorysConfig(event);
settings.load(event);
Expand All @@ -107,6 +114,7 @@ public Item getTabIconItem() {

blocks.preInit(event);
items.preInit(event);
achievements.preInit(event);

blocks.register(event);
items.register(event);
Expand All @@ -119,6 +127,7 @@ public void init(FMLInitializationEvent event) {
RMLog.info("Registering Recipes");
blocks.init(event);
items.init(event);
achievements.init(event);

RMLog.info("Registering everything else");

Expand Down Expand Up @@ -158,9 +167,10 @@ private void registerRecipieSorter() {
public void postinit(FMLPostInitializationEvent event) {
blocks.postinit(event);
items.postinit(event);
achievements.postinit(event);

registerRecipieSorter();

MekanismPlugin.load();

RMLog.info("Registered " + Register.getRegisteredBlocks() + " block(s)");
Expand All @@ -174,4 +184,9 @@ public void postinit(FMLPostInitializationEvent event) {
Thread check = new Thread(versionCheker, RorysGlobal.MODID + " Version Check");
check.start();
}

@EventHandler
public void serverLoad(FMLServerStartingEvent event) {
commands.serverLoad(event);
}
}
4 changes: 2 additions & 2 deletions src/main/java/me/roryclaasen/rorysmod/core/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class Version implements Runnable {

public boolean haveWarnedVersionOutOfDate = false;

public Version(String version) {
check = new VersionCheck("GOGO98901", "RorysMod", version);
public Version() {
check = new VersionCheck("GOGO98901", "RorysMod", RorysGlobal.VERSION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.init;

import java.util.ArrayList;
import java.util.List;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import me.roryclaasen.rorysmod.core.RorysGlobal;
import me.roryclaasen.rorysmod.core.RorysMod;
import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;

public class ModAchievements implements ModInterface {

public AchievementPage page;
private static final String BASE_ID = "achievement.";

private List<Achievement> all;

public Achievement solderDust, solderArmor, solderArmorFull;

@Override
public void preInit(FMLPreInitializationEvent event) {
all = new ArrayList<Achievement>();
}

@Override
public void init(FMLInitializationEvent event) {
solderDust = createAchievement("solder_dust", 1, -3, RorysMod.items.solderDust, null);
solderArmor = createAchievement("solder_arm", 2, -4, RorysMod.items.solderChest, solderDust);
solderArmorFull = createAchievement("solder_armFull", 4, -4, RorysMod.items.solderHelm, solderArmor).setSpecial();

page = new AchievementPage(RorysGlobal.NAME, (Achievement[]) all.toArray(new Achievement[] {}));
AchievementPage.registerAchievementPage(page);
}

@Override
public void postinit(FMLPostInitializationEvent event) {}

private Achievement createAchievement(String name, int x, int y, Item item, Achievement parent) {
Achievement temp = new Achievement(BASE_ID + name, name, x, y, item, parent);
all.add(temp);
return temp;
}

public List<Achievement> getAllAchivements() {
return page.getAchievements();
}
}
23 changes: 23 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/core/init/ModCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.init;

import cpw.mods.fml.common.event.FMLServerStartingEvent;
import me.roryclaasen.rorysmod.command.CommandPing;

public class ModCommands {

public void serverLoad(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandPing());
}
}
10 changes: 9 additions & 1 deletion src/main/java/me/roryclaasen/rorysmod/core/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import ic2.api.item.IC2Items;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.Recipes;
import me.roryclaasen.rorysmod.core.RorysMod;
import me.roryclaasen.rorysmod.core.register.Register;
import me.roryclaasen.rorysmod.item.ItemCoil;
import me.roryclaasen.rorysmod.item.ItemDust;
Expand All @@ -29,10 +30,12 @@
import me.roryclaasen.rorysmod.item.tools.ItemRifle;
import me.roryclaasen.rorysmod.item.tools.ItemSolderingIron;
import me.roryclaasen.rorysmod.util.RMLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;

public class ModItems implements ModInterface {
Expand Down Expand Up @@ -74,7 +77,12 @@ public void preInit(FMLPreInitializationEvent event) {
filament = new ItemBase("filament");
cpu = new ItemBase("cpu");
solderingIron = new ItemSolderingIron("solderingIron");
solderDust = new ItemDust("dustSolder");
solderDust = new ItemDust("dustSolder") {
public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
super.onCreated(itemStack, world, player);
player.triggerAchievement(RorysMod.achievements.solderDust);
}
};
solderIngot = new ItemIngot("ingotSolder");
solderPlate = new ItemPlate("plateSolder");
solderWire = new ItemBase("wireSolder");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import me.roryclaasen.rorysmod.core.RorysMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.stats.Achievement;

public class CommonProxy {

public void init(FMLInitializationEvent e) {}
public void init(FMLInitializationEvent e) {
for (Achievement achi : RorysMod.achievements.getAllAchivements()) {
achi.registerStat();
}
}

public EntityPlayer getPlayerEntity(MessageContext ctx) {
return ctx.getServerHandler().playerEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void onPlayerSleepInBedEvent(PlayerSleepInBedEvent event) throws IllegalA
World worldObj = player.worldObj;

if (!worldObj.isRemote) {
player.getDisplayName();
if (player.isPlayerSleeping() || !player.isEntityAlive()) {
event.result = EntityPlayer.EnumStatus.OTHER_PROBLEM;
return;
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/me/roryclaasen/rorysmod/item/ItemSolderArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;

import me.roryclaasen.rorysmod.core.RorysGlobal;
import me.roryclaasen.rorysmod.core.RorysMod;
import me.roryclaasen.rorysmod.item.base.ItemBaseArmor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -31,7 +32,25 @@ public ItemSolderArmor(String unlocalizedName, int type) {
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
super.onArmorTick(world, player, itemStack);

// TODO add achievement
ItemStack[] armor = player.inventory.armorInventory;

boolean all = true;

for (ItemStack item : armor) {
if (item == null) {
all = false;
continue;
}
if (!(item.getItem() instanceof ItemSolderArmor)) {
all = false;
continue;
}
player.triggerAchievement(RorysMod.achievements.solderArmor);
}

if (all) {
player.triggerAchievement(RorysMod.achievements.solderArmorFull);
}
}

@SuppressWarnings({ "unchecked", "rawtypes" })
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/assets/rorysmod/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,13 @@ recipie.rorysmod.shapeless=Shapeless

//-------------------{ MISC }-------------------
infuse.solder=Solder

//---------------{ Achievements }---------------
achievement.solder_dust=Smashing up and mixing some metal award
achievement.solder_dust.desc=White Powder... its not cocaine

achievement.solder_arm=A piece of armour
achievement.solder_arm.desc=Even Gold would be better than this

achievement.solder_armFull=Why Have you done this
achievement.solder_armFull.desc=Create A full set of solder armour

0 comments on commit 0ccd60a

Please sign in to comment.