-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Effortless Building Integration + JEI Recipe Category ID
- Loading branch information
1 parent
7105eba
commit a1e1f14
Showing
16 changed files
with
407 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/java/com/nomiceu/nomilabs/integration/effortlessbuilding/GenericReachUpgrade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.nomiceu.nomilabs.integration.effortlessbuilding; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.nomiceu.nomilabs.config.LabsConfig; | ||
import com.nomiceu.nomilabs.util.LabsTranslate; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.*; | ||
import net.minecraft.world.World; | ||
import nl.requios.effortlessbuilding.BuildConfig; | ||
import nl.requios.effortlessbuilding.EffortlessBuilding; | ||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class GenericReachUpgrade { | ||
public static final int CREATIVE_LEVEL = -1; | ||
public static Map<Integer, ReachInfo> REACH_MAP = ImmutableMap.of( | ||
-1, new ReachInfo(BuildConfig.reach.maxReachCreative, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReachCreative, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlacedCreative), | ||
0, new ReachInfo(BuildConfig.reach.maxReachLevel0, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach0, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced0), | ||
1, new ReachInfo(BuildConfig.reach.maxReachLevel1, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach1, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced1), | ||
2, new ReachInfo(BuildConfig.reach.maxReachLevel2, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach2, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced2), | ||
3, new ReachInfo(BuildConfig.reach.maxReachLevel3, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach3, | ||
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced3) | ||
); | ||
|
||
// A complete overwrite so everything can be localized! | ||
public static ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand, int upgradeLevel) { | ||
if (player.isCreative()) { | ||
if (world.isRemote) { | ||
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.creative.1")); | ||
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.creative.2")); | ||
} | ||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); | ||
} | ||
|
||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); | ||
int currentLevel = modifierSettings.getReachUpgrade(); | ||
if (currentLevel < upgradeLevel - 1 && currentLevel >= 0) { | ||
if (world.isRemote) EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.previous", upgradeLevel - 1)); | ||
} | ||
if (currentLevel == upgradeLevel - 1) { | ||
ReachInfo currentReach = REACH_MAP.get(upgradeLevel - 1); | ||
ReachInfo newReach = REACH_MAP.get(upgradeLevel); | ||
modifierSettings.setReachUpgrade(upgradeLevel); | ||
|
||
if (world.isRemote) { | ||
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.1")); | ||
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.2", | ||
currentReach.axis, newReach.axis)); | ||
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.3", | ||
currentReach.distance, newReach.distance)); | ||
} | ||
player.setHeldItem(hand, ItemStack.EMPTY); | ||
|
||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup")); | ||
player.playSound(soundEvent, 1f, 1f); | ||
|
||
return new ActionResult<>(EnumActionResult.PASS, ItemStack.EMPTY); | ||
} else if (currentLevel > upgradeLevel - 1) { | ||
if (world.isRemote) EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.already_used")); | ||
} | ||
return new ActionResult<>(EnumActionResult.FAIL, player.getHeldItem(hand)); | ||
} | ||
public static void addInformation(List<String> tooltip, int level) { | ||
ReachInfo reach = REACH_MAP.get(level); | ||
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.1")); | ||
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.2", reach.axis)); | ||
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.3", reach.distance)); | ||
} | ||
|
||
public static class ReachInfo { | ||
public final int distance; | ||
public final int axis; | ||
public final int maxBlocks; | ||
|
||
public ReachInfo(int distance, int axis, int maxBlocks) { | ||
this.distance = distance; | ||
this.axis = axis; | ||
this.maxBlocks = maxBlocks; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/nomiceu/nomilabs/mixin/effortlessbuilding/ItemReachUpgrade1Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nomiceu.nomilabs.mixin.effortlessbuilding; | ||
|
||
import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade; | ||
import net.minecraft.client.util.ITooltipFlag; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade1; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 1. | ||
*/ | ||
@Mixin(value = ItemReachUpgrade1.class, remap = false) | ||
public class ItemReachUpgrade1Mixin { | ||
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true) | ||
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) { | ||
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 1)); | ||
} | ||
|
||
@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true) | ||
@SideOnly(Side.CLIENT) | ||
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) { | ||
GenericReachUpgrade.addInformation(tooltip, 1); | ||
ci.cancel(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/nomiceu/nomilabs/mixin/effortlessbuilding/ItemReachUpgrade2Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nomiceu.nomilabs.mixin.effortlessbuilding; | ||
|
||
import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade; | ||
import net.minecraft.client.util.ITooltipFlag; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade2; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 2. | ||
*/ | ||
@Mixin(value = ItemReachUpgrade2.class, remap = false) | ||
public class ItemReachUpgrade2Mixin { | ||
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true) | ||
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) { | ||
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 2)); | ||
} | ||
|
||
@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true) | ||
@SideOnly(Side.CLIENT) | ||
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) { | ||
GenericReachUpgrade.addInformation(tooltip, 2); | ||
ci.cancel(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/nomiceu/nomilabs/mixin/effortlessbuilding/ItemReachUpgrade3Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nomiceu.nomilabs.mixin.effortlessbuilding; | ||
|
||
import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade; | ||
import net.minecraft.client.util.ITooltipFlag; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade3; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 3. | ||
*/ | ||
@Mixin(value = ItemReachUpgrade3.class, remap = false) | ||
public class ItemReachUpgrade3Mixin { | ||
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true) | ||
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) { | ||
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 3)); | ||
} | ||
|
||
@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true) | ||
@SideOnly(Side.CLIENT) | ||
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) { | ||
GenericReachUpgrade.addInformation(tooltip, 3); | ||
ci.cancel(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/nomiceu/nomilabs/mixin/effortlessbuilding/ReachHelperMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.nomiceu.nomilabs.mixin.effortlessbuilding; | ||
|
||
import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; | ||
import nl.requios.effortlessbuilding.helper.ReachHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
/** | ||
* Changes the actual max axis distance and max blocks. | ||
*/ | ||
@Mixin(value = ReachHelper.class, remap = false) | ||
public class ReachHelperMixin { | ||
@Inject(method = "getMaxBlocksPerAxis", at = @At("HEAD"), cancellable = true) | ||
private static void getNewMaxBlocksPerAxis(EntityPlayer player, CallbackInfoReturnable<Integer> cir) { | ||
if (player.isCreative()) { | ||
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(GenericReachUpgrade.CREATIVE_LEVEL).axis); | ||
return; | ||
} | ||
int level = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade(); | ||
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(level).axis); | ||
} | ||
|
||
@Inject(method = "getMaxBlocksPlacedAtOnce", at = @At("HEAD"), cancellable = true) | ||
private static void getNewMaxBlocksPlacedAtOnce(EntityPlayer player, CallbackInfoReturnable<Integer> cir) { | ||
if (player.isCreative()) { | ||
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(GenericReachUpgrade.CREATIVE_LEVEL).maxBlocks); | ||
return; | ||
} | ||
int level = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade(); | ||
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(level).maxBlocks); | ||
} | ||
} |
Oops, something went wrong.