Skip to content

Commit

Permalink
Fix the algorithm to trigger the appropriate event handlers when brea…
Browse files Browse the repository at this point in the history
…king blocks.

Additionally do some minor cleanup and clarification and remove the silk touch option. Also add copyright to each header.

closes #13
  • Loading branch information
arlyon committed Jul 2, 2018
1 parent ab83b4b commit f3c61e3
Show file tree
Hide file tree
Showing 19 changed files with 648 additions and 267 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ out/
*.iml
*.ipr
*.iws
.todos.json
\.DS_Store
.todos.json
\.DS_Store
*.properties
41 changes: 29 additions & 12 deletions src/main/java/arlyon/veining/Configuration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
/*
* veining (c) by Alexander Lyon
*
* veining is licensed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*
* You should have received a copy of the license along with this
* work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>
*/

/*
* veining (c) by arlyon
*
* veining is licensed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*
* You should have received a copy of the license along with this
* work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>
*/

package arlyon.veining;

import arlyon.veining.network.VeiningSettingsMessage;
import arlyon.veining.network.PacketHandler;
import arlyon.veining.network.VeiningSettingsMessage;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
Expand All @@ -10,7 +30,7 @@

/**
* Created by Alexander Lyon on 30.07.2017.
*
* <p>
* Controls the configurable options in the mod config menu.
*/
@Config(modid = Veining.MOD_ID)
Expand All @@ -33,18 +53,14 @@ public static class ServerSide {

@Config.Name("Veining Durability Cost")
@Config.Comment("Controls how much damage is done to the pickaxe per ore when the enchantment crumbles a vein.")
@Config.RangeInt(min=0, max=5)
@Config.RangeInt(min = 0, max = 5)
public int durabilityDamage = 2;

@Config.Name("Rarity (%)")
@Config.Comment("Controls how rare the enchantment is (with 100% being as the mod was intended). It is recommended to keep it between 80% and 120%, and more statistics can be found on the wiki.")
@Config.RangeInt(min=0, max=200)
@Config.RangeInt(min = 0, max = 200)
public int enchantmentRarity = 100;

@Config.Name("Silk Touch")
@Config.Comment("Determines whether the enchantment should respect silk touch.")
public boolean silkTouch = true;

@Config.Name("Maximum Blocks To Break")
@Config.Comment("Puts a limit on the number of blocks to break. Zero for no limit.")
@Config.RangeInt(min = 0)
Expand Down Expand Up @@ -74,6 +90,7 @@ private static class EventHandler {

/**
* Saves the config locally and also sends critical values to the server when the config changes.
*
* @param event The config change event
*/
@SubscribeEvent
Expand All @@ -82,10 +99,10 @@ public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event
ConfigManager.sync(Veining.MOD_ID, Config.Type.INSTANCE);

PacketHandler.INSTANCE.sendToServer(
new VeiningSettingsMessage(
clientSide.disableWhenCrouched,
clientSide.disableWhenStanding
)
new VeiningSettingsMessage(
clientSide.disableWhenCrouched,
clientSide.disableWhenStanding
)
);
}
}
Expand Down
58 changes: 42 additions & 16 deletions src/main/java/arlyon/veining/Veining.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* veining (c) by Alexander Lyon
*
* veining is licensed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*
* You should have received a copy of the license along with this
* work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>
*/

/*
* veining (c) by arlyon
*
* veining is licensed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*
* You should have received a copy of the license along with this
* work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>
*/

package arlyon.veining;

import arlyon.veining.network.PlayerSettings;
Expand All @@ -19,34 +39,33 @@
* The main entry point into the mod.
*/
@Mod(
modid = Veining.MOD_ID,
name = Veining.MOD_NAME,
version = Veining.MOD_VERSION,
updateJSON = Veining.UPDATE_JSON,
acceptedMinecraftVersions = Veining.MINECRAFT_VERSIONS,
dependencies = "required-after:forge@[14.23.1,);after:tconstruct@[1.12-2.9,);after:mantle@[1.12-1.3.1,)"
modid = Veining.MOD_ID,
name = Veining.MOD_NAME,
version = Veining.MOD_VERSION,
updateJSON = Veining.UPDATE_JSON,
acceptedMinecraftVersions = Veining.MINECRAFT_VERSIONS,
dependencies = "required-after:forge@[14.23.1,);after:tconstruct@[1.12-2.9,);after:mantle@[1.12-1.3.1,)"
)
public class Veining {

static final String MOD_NAME = "Veining";
public static final String MOD_ID = "veining";
static final String MOD_VERSION = "1.3.1";
static final String UPDATE_JSON = "https://raw.githubusercontent.com/arlyon/veining/1.12.x/update.json";
static final String MINECRAFT_VERSIONS = "[1.12.0, 1.12.2]"; // starting with 1.12, up to 1.12.2

public static final VeiningEnchantment veining = new VeiningEnchantment(
net.minecraft.enchantment.Enchantment.Rarity.UNCOMMON,
EntityEquipmentSlot.MAINHAND
net.minecraft.enchantment.Enchantment.Rarity.UNCOMMON,
EntityEquipmentSlot.MAINHAND
);

public static final Map<Integer, PlayerSettings> playerSettings = new HashMap<>();
static final String MOD_NAME = "Veining";
static final String MOD_VERSION = "1.3.1";
static final String UPDATE_JSON = "https://raw.githubusercontent.com/arlyon/veining/1.12.x/update.json";
static final String MINECRAFT_VERSIONS = "[1.12.0, 1.12.2]"; // starting with 1.12, up to 1.12.2
public static Logger log;

@SidedProxy(clientSide = "arlyon.veining.proxy.ProxyClient", serverSide = "arlyon.veining.proxy.ProxyServer")
private static ProxyCommon proxy;

/**
* Passes the pre-initialization event onwards to the proxy.
*
* @param e The pre-initialization event.
*/
@Mod.EventHandler
Expand All @@ -57,17 +76,23 @@ public void preInit(FMLPreInitializationEvent e) {

/**
* Passes the initialization event onwards to the proxy.
*
* @param e The initialization event.
*/
@Mod.EventHandler
public void init(FMLInitializationEvent e) { proxy.init(e); }
public void init(FMLInitializationEvent e) {
proxy.init(e);
}

/**
* Passes the post-initialization event onwards to the proxy.
*
* @param e The post-initialization event.
*/
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) { proxy.postInit(e); }
public void postInit(FMLPostInitializationEvent e) {
proxy.postInit(e);
}

/**
* Sets up some event handlers.
Expand All @@ -77,6 +102,7 @@ public static class EnchantmentHandler {

/**
* Registers the veining enchantment when the VeiningEnchantment register event fires.
*
* @param event The enchantment register event.
*/
@SubscribeEvent
Expand Down
Loading

0 comments on commit f3c61e3

Please sign in to comment.