Skip to content

Commit

Permalink
Fixed the enchantment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexatos committed Apr 20, 2015
1 parent 759a7a8 commit cb0e431
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
10 changes: 8 additions & 2 deletions src/main/java/pl/asie/lib/AnvilDyeTweak.java
@@ -1,13 +1,17 @@
package pl.asie.lib;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.init.Items;
import net.minecraftforge.event.AnvilUpdateEvent;
import pl.asie.lib.util.ChatUtils;

public class AnvilDyeTweak {
@SubscribeEvent
@SubscribeEvent(priority = EventPriority.LOWEST)
public void event(AnvilUpdateEvent e) {
if(e.left == null || e.right == null || e.left.getItem() == null || e.right.getItem() == null || e.isCanceled()) {
return;
}
if(e.right.getItem().equals(Items.dye) && e.right.stackSize == e.left.stackSize) {
e.cost = e.left.isItemStackDamageable() ? 7 : e.left.stackSize * 5;
String colorPrefix = "\u00a7" + Integer.toHexString(ChatUtils.dyeToChat(e.right.getItemDamage()));
Expand All @@ -24,7 +28,9 @@ public void event(AnvilUpdateEvent e) {
name = name.substring(1);
}
}
if(e.output == null) e.output = e.left.copy();
if(e.output == null) {
e.output = e.left.copy();
}
e.output.setStackDisplayName(colorPrefix + name);
}
}
Expand Down
Expand Up @@ -17,7 +17,7 @@ public EnchantmentBetterBane(int p_i1923_1_) {
@Override
public String getTranslatedName(int p_77316_1_) {
String s = StatCollector.translateToLocal(this.getName());
return s + " \u2468" /*+ StatCollector.translateToLocal("enchantment.computronics.level.9")*/;
return s + " \u2468" /*+ StatCollector.translateToLocal("enchantment.asielib.level.9")*/;
}

@Override
Expand Down
63 changes: 23 additions & 40 deletions src/main/java/pl/asie/lib/tweak/enchantment/EnchantmentTweak.java
@@ -1,5 +1,6 @@
package pl.asie.lib.tweak.enchantment;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.enchantment.Enchantment;
Expand Down Expand Up @@ -40,59 +41,41 @@ public static void registerBaneEnchantment(int enchID) {
throw new IllegalArgumentException("No valid enchantment id! " + EnchantmentBetterBane.class + " Enchantment ID:" + enchID);
}

@SubscribeEvent
@SubscribeEvent(priority = EventPriority.LOWEST)
public void anvilEvent(AnvilUpdateEvent e) {
if(e.left.isItemStackDamageable() && e.left.isItemEnchanted()
&& e.right.getItem() == Items.fermented_spider_eye) {
if(e.right.stackSize == 64) {
e.output = e.left.copy();
e.cost = 37;
addBaneEnchantment(e.output, 9);
} else {
e.output = null;
if(e.isCancelable()) {
e.setCanceled(true);
}
}
} else if(hasBaneEnchantment(e.right) || hasBaneEnchantment(e.left)) {
e.output = null;
if(e.isCancelable()) {
e.setCanceled(true);
}
if(e.left == null || e.right == null || e.left.getItem() == null || e.right.getItem() == null || e.isCanceled()) {
return;
}
}

/*@SubscribeEvent
public void enchEvent(TickEvent.ClientTickEvent e) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null && player.getCurrentEquippedItem() != null && hasBaneEnchantment(player.getCurrentEquippedItem())
&& player.getCurrentEquippedItem().isItemStackDamageable()) {
RayTracing.instance().fire(20.0F);
MovingObjectPosition pos = RayTracing.instance().getTarget();
if(pos != null && pos.typeOfHit != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
Entity entity = pos.entityHit;
if(entity != null && entity instanceof EntityLivingBase
&& ((EntityLivingBase) entity).getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD
&& entity.hurtResistantTime <= 10) {
try {
AsieLibMod.packet.sendToServer(
AsieLibMod.packet.create(Packets.ATTACK_ENTITY)
.writeInt(entity.getEntityId())
} catch(IOException e1) {
//NO-OP
if(e.left.isItemStackDamageable() && e.left.isItemEnchanted()) {
if(e.right.getItem() == Items.fermented_spider_eye && !hasBaneEnchantment(e.left)) {
if(e.right.stackSize == 64) {
e.output = e.left.copy();
e.cost = 37;
if(!addBaneEnchantment(e.output, 9)) {
e.output = null;
if(e.isCancelable()) {
e.setCanceled(true);
}
}
} else {
e.output = null;
if(e.isCancelable()) {
e.setCanceled(true);
}
}
}
}
}*/
}

@SubscribeEvent
public void enchEvent(TickEvent.PlayerTickEvent e) {
EntityPlayer player = e.player;
if(player.worldObj.isRemote) {
return;
}
if(player.getCurrentEquippedItem() != null && hasBaneEnchantment(player.getCurrentEquippedItem()) && player.getCurrentEquippedItem().isItemStackDamageable()) {
if(player.getCurrentEquippedItem() != null && hasBaneEnchantment(player.getCurrentEquippedItem())
&& player.getCurrentEquippedItem().isItemStackDamageable()) {

RayTracer.instance().fire(player, 10.0);
MovingObjectPosition target = RayTracer.instance().getTarget();
if(target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
Expand Down

0 comments on commit cb0e431

Please sign in to comment.