Skip to content

Commit

Permalink
bump version and fix client/serverside problems
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Aug 5, 2017
1 parent 74c3d45 commit 1f6119a
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
version 1.2.3

- fix serverside and clientside
- add rarity setting

version 1.2.2

version 1.2.1

version 1.2

- added enchantment book to creative
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.2.2"
version = "1.2.3"
group = "arlyon.felling" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "felling"

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/arlyon/felling/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Created by Alexander Lyon on 30.07.2017.
*
* Controls the configurable options in the mod config menu.
*/

@Config(modid = Constants.MODID)
Expand Down Expand Up @@ -35,6 +37,11 @@ public class Configuration {
@Config.RangeInt(min=0, max=200)
public static int leafMultiplier = 100;

@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)
public static int enchantmentRarity = 100;

@Mod.EventBusSubscriber
private static class EventHandler {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/arlyon/felling/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public class Constants {
public static final String MOD_NAME = "Felling";
public static final String MODID = "felling";
public static final String VERSION = "1.2.2";
public static final String VERSION = "1.2.3";
public static final Enchantment felling = new Enchantment(net.minecraft.enchantment.Enchantment.Rarity.UNCOMMON, EntityEquipmentSlot.MAINHAND);
}
42 changes: 27 additions & 15 deletions src/main/java/arlyon/felling/Enchantment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,49 @@

import java.util.Arrays;

/**
* The enchantment class for the Felling enchantment.
*/
public class Enchantment extends net.minecraft.enchantment.Enchantment {

// creates a new enchantment type called axe that can be applied on any tool with the class axe.
private static EnumEnchantmentType AXE = EnumHelper.addEnchantmentType("AXE", item -> item.getToolClasses(new ItemStack(item)).stream().anyMatch(toolClass -> toolClass.equals("axe")));
/**
* Axe enchantment type.
*/
public static EnumEnchantmentType AXE = EnumHelper.addEnchantmentType("AXE", item -> {
assert item != null;
return item.getToolClasses(new ItemStack(item)).stream().anyMatch(toolClass -> toolClass.equals("axe"));
});

public Enchantment(Rarity rarityIn, EntityEquipmentSlot... slots) {
/**
* Sets name and registry name and assigns the proper predicate.
*
* @param rarityIn the rarity of the enchantment
* @param slots the slots in which the enchantment is valid
*/
Enchantment(Rarity rarityIn, EntityEquipmentSlot... slots) {
super(rarityIn, AXE, slots);
setName("felling");
setRegistryName("felling");

// add it to the creative tab
EnumEnchantmentType[] enchantmentTypes = CreativeTabs.TOOLS.getRelevantEnchantmentTypes();
enchantmentTypes = Arrays.copyOf(enchantmentTypes, enchantmentTypes.length+1);
enchantmentTypes[enchantmentTypes.length-1] = AXE;

CreativeTabs.TOOLS.setRelevantEnchantmentTypes(enchantmentTypes);
}

/**
* Returns the minimal value of enchantability needed on the enchantment level passed.
*
* Felling I - 20
* Felling II - 35
*
* @param enchantmentLevel The level you want to get minimum enchantability weight for.
* @return Minimus value of enchantability for the given enchantment level.
*/
public int getMinEnchantability(int enchantmentLevel) { return 5 + (enchantmentLevel) * 15; }
public int getMinEnchantability(int enchantmentLevel) { return ((5 + (enchantmentLevel) * 15) * Configuration.enchantmentRarity) / 100; }

/**
* Returns the maximum value of enchantability needed on the enchantment level passed.
* Felling I - 35
* Felling II - 50
*
* @param enchantmentLevel The level you want to get maximun enchantability weight for.
* @return Maximum value of enchantability for the given enchantment level.
*/
public int getMaxEnchantability(int enchantmentLevel) {
return this.getMinEnchantability(enchantmentLevel) + 50;
return this.getMinEnchantability(enchantmentLevel) + 15;
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/arlyon/felling/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
import java.util.Random;

/**
* Handles the destroying of trees with the felling enchantment.
* The event handler container for both the FellingEvent and the RegistryEvent
*/

public class EventHandler {

/**
* The felling event subscriber class, which contains all the required functions for the subscriber.
*/
@Mod.EventBusSubscriber(modid = Constants.MODID)
public static class FellingEventHandler {

/**
* Used to determine which part of the tree a block is.
*/
private enum TreePart {
LEAF,
LOG,
Expand Down Expand Up @@ -80,6 +86,11 @@ private static TreePart getTreePart(Block block) {
*/
@SubscribeEvent
public static void fellTreeSubscriber(BlockEvent.BreakEvent event) {

if (event.getWorld().isRemote) {
return;
}

EntityPlayer thePlayer = event.getPlayer();
ItemStack mainHandItem = thePlayer.getHeldItemMainhand();
int enchantmentLevel = EnchantmentHelper.getEnchantmentLevel(Constants.felling, mainHandItem);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/arlyon/felling/proxy/ProxyClient.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package arlyon.felling.proxy;

import arlyon.felling.Enchantment;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import java.util.Arrays;

public class ProxyClient extends ProxyCommon {

@Override
public void preInit(FMLPreInitializationEvent e) {

super.preInit(e);

// add it to the creative tab
EnumEnchantmentType[] enchantmentTypes = CreativeTabs.TOOLS.getRelevantEnchantmentTypes();
enchantmentTypes = Arrays.copyOf(enchantmentTypes, enchantmentTypes.length+1);
enchantmentTypes[enchantmentTypes.length-1] = Enchantment.AXE;
CreativeTabs.TOOLS.setRelevantEnchantmentTypes(enchantmentTypes);

}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "felling",
"name": "Felling",
"description": "Uncovers an ancient enchantment allows you to fell trees with a single swing.",
"version": "1.2.2",
"version": "1.2.3",
"mcversion": "1.11.2",
"url": "https://git.arlyon.co/minecraft/Felling",
"updateUrl": "",
Expand Down

0 comments on commit 1f6119a

Please sign in to comment.