forked from DaedalusGame/EmbersRekindled
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Ember Modifier, when Environmental Tech is loaded
- Loading branch information
1 parent
86a59f3
commit e179e43
Showing
23 changed files
with
315 additions
and
4 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
47 changes: 47 additions & 0 deletions
47
src/main/java/teamroots/embers/compat/environmentaltech/BlockModifierEmber.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,47 @@ | ||
package teamroots.embers.compat.environmentaltech; | ||
|
||
import com.valkyrieofnight.et.api.m_multiblocks.m_components.m_modifiers.attribute.AttributeForgeEnergyMultiplier; | ||
import com.valkyrieofnight.et.m_multiblocks.m_components.m_modifiers.block.BlockModifier; | ||
import com.valkyrieofnight.um.api.attribute.IAttribute; | ||
import com.valkyrieofnight.um.api.modifier.ModifierID; | ||
import com.valkyrieofnight.vlib.core.util.client.LangUtil; | ||
import net.minecraft.client.util.ITooltipFlag; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.config.ConfigCategory; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import teamroots.embers.Embers; | ||
import teamroots.embers.config.ConfigCompat; | ||
|
||
import java.util.List; | ||
|
||
public class BlockModifierEmber extends BlockModifier { | ||
public static final ModifierID EMBER = new ModifierID(Embers.MODID, "ember"); | ||
|
||
public BlockModifierEmber() { | ||
super("ember", TileModifierEmber.class, new ConfigCategory("")); | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
public boolean hasShiftTooltipInfo() { | ||
return true; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
public void addShiftTooltipInfo(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { | ||
tooltip.add(LangUtil.toLoc("tooltip.embers.modifier_ember.info")); | ||
} | ||
|
||
@Override | ||
public void addAttributes(List<IAttribute> list, ConfigCategory configCategory) { | ||
list.add(EmbersAttributes.EM_EMBER); | ||
list.add(new AttributeForgeEnergyMultiplier((float) ConfigCompat.ENVIRONMENTAL_TECH.energy_increase / 100.0F)); | ||
} | ||
|
||
@Override | ||
public ModifierID getModifierID() { | ||
return EMBER; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/teamroots/embers/compat/environmentaltech/EmbersAttributes.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,17 @@ | ||
package teamroots.embers.compat.environmentaltech; | ||
|
||
import com.valkyrieofnight.um.api.attribute.AttributeID; | ||
import com.valkyrieofnight.um.api.attribute.IAttribute; | ||
import com.valkyrieofnight.um.api.base.attributes.generic.AttributeBoolean; | ||
|
||
public class EmbersAttributes { | ||
public static final AttributeID EM_EMBER_ID = new AttributeID("embers", "ember", AttributeBoolean.CALCULATOR_OR); | ||
public static IAttribute EM_EMBER; | ||
|
||
public EmbersAttributes() { | ||
} | ||
|
||
static { | ||
EM_EMBER = new AttributeBoolean(EM_EMBER_ID, true); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/teamroots/embers/compat/environmentaltech/EnvironmentalTechIntegration.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,39 @@ | ||
package teamroots.embers.compat.environmentaltech; | ||
|
||
import com.valkyrieofnight.et.ETMod; | ||
import com.valkyrieofnight.et.m_multiblocks.m_components.m_modifiers.features.MBlocks; | ||
import com.valkyrieofnight.et.m_multiblocks.m_voidminer.features.VMBlocks; | ||
import com.valkyrieofnight.et.m_resources.features.ETRBlocks; | ||
import com.valkyrieofnight.et.m_resources.features.ETRItems; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.crafting.IRecipe; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.event.RegistryEvent; | ||
import net.minecraftforge.oredict.ShapedOreRecipe; | ||
import teamroots.embers.Embers; | ||
import teamroots.embers.register.BlockRegister; | ||
import teamroots.embers.register.ItemRegister; | ||
|
||
import static teamroots.embers.recipe.RecipeRegistry.getRL; | ||
|
||
public class EnvironmentalTechIntegration { | ||
public static Block MODIFIER_EMBER = new BlockModifierEmber(); | ||
|
||
public static void registerAll() { | ||
VMBlocks.getInstance().addBlock(MODIFIER_EMBER); | ||
} | ||
|
||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { | ||
event.getRegistry().register(new ShapedOreRecipe(new ResourceLocation(Embers.MODID, "modifier_ember"), new ItemStack(MODIFIER_EMBER, 1), true, new Object[]{ | ||
"ABA", | ||
"CDC", | ||
"EFE", | ||
'A', ItemRegister.EMBER_CLUSTER, | ||
'B', BlockRegister.EMBER_BORE, | ||
'C', ETRBlocks.MICA, | ||
'D', MBlocks.MODIFIER_NULL, | ||
'E', "plateDawnstone", | ||
'F', ETRItems.LONSDALEITE_CRYSTAL}).setMirrored(true).setRegistryName(getRL("modifier_ember"))); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/teamroots/embers/compat/environmentaltech/TileModifierEmber.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,8 @@ | ||
package teamroots.embers.compat.environmentaltech; | ||
|
||
import com.valkyrieofnight.et.base.tile.ETTileSlave; | ||
|
||
public class TileModifierEmber extends ETTileSlave { | ||
public TileModifierEmber() { | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/teamroots/embers/config/compat/EnvironmentalTechCategory.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,14 @@ | ||
package teamroots.embers.config.compat; | ||
|
||
import net.minecraftforge.common.config.Config; | ||
|
||
public class EnvironmentalTechCategory { | ||
@Config.RequiresMcRestart | ||
@Config.Name("Energy Increase") | ||
@Config.RangeInt(min = 0) | ||
@Config.Comment({ | ||
"How much more energy the modifier will consume", | ||
"The value is entered as a percentage, so 20 is 20% more energy" | ||
}) | ||
public int energy_increase = 20; | ||
} |
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
54 changes: 54 additions & 0 deletions
54
src/main/java/teamroots/embers/mixin/environmentaltech/TileContVoidMinerBaseMixin.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,54 @@ | ||
package teamroots.embers.mixin.environmentaltech; | ||
|
||
import com.valkyrieofnight.et.base.tile.ETControllerEConsumer; | ||
import com.valkyrieofnight.et.m_multiblocks.m_voidminer.tile.TileContVoidMinerBase; | ||
import com.valkyrieofnight.vliblegacy.lib.inventory.VLItemHandler; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.WeightedRandom; | ||
import net.minecraftforge.items.ItemHandlerHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import teamroots.embers.compat.environmentaltech.EmbersAttributes; | ||
import teamroots.embers.recipe.BoreOutput; | ||
import teamroots.embers.recipe.RecipeRegistry; | ||
import teamroots.embers.util.EmberGenUtil; | ||
import teamroots.embers.util.WeightedItemStack; | ||
|
||
import java.util.Random; | ||
|
||
@Mixin(value = TileContVoidMinerBase.class, remap = false) | ||
public abstract class TileContVoidMinerBaseMixin extends ETControllerEConsumer { | ||
private TileContVoidMinerBaseMixin(int capacity) { | ||
super(capacity); | ||
} | ||
|
||
@Shadow | ||
private Random rand; | ||
|
||
@Shadow | ||
private BlockPos drillTip; | ||
|
||
@Shadow | ||
private VLItemHandler output; | ||
|
||
@Inject(method = "onProcessComplete", at = @At("HEAD")) | ||
private void checkEmber(CallbackInfo ci) { | ||
Object modifierExists = this.modifierHandler.getAttributeFinalValue(EmbersAttributes.EM_EMBER.getAttributeID()); | ||
if (modifierExists != null) { | ||
if (rand.nextFloat() < EmberGenUtil.getEmberDensity(this.getWorld().getSeed(), drillTip.getX(), drillTip.getZ())) { | ||
BoreOutput possible_output = RecipeRegistry.getBoreOutput(this.getWorld(), drillTip); | ||
if (possible_output != null) { | ||
if (!possible_output.stacks.isEmpty()) { | ||
WeightedItemStack picked = WeightedRandom.getRandomItem(rand, possible_output.stacks); | ||
ItemHandlerHelper.insertItem(output, picked.getStack().copy(), false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
src/main/java/teamroots/embers/mixin/valkyrielib/VLBlockStandardMixin.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,35 @@ | ||
package teamroots.embers.mixin.valkyrielib; | ||
|
||
import com.valkyrieofnight.vliblegacy.lib.block.adv.VLBlockStandard; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import teamroots.embers.Embers; | ||
|
||
@Mixin(value = VLBlockStandard.class, remap = false) | ||
public class VLBlockStandardMixin { | ||
@Shadow | ||
protected String blockName; | ||
|
||
@ModifyArg(method = "<init>(Ljava/lang/String;Lnet/minecraft/block/material/Material;)V", at = @At(value = "INVOKE", target = "Lcom/valkyrieofnight/vliblegacy/lib/block/adv/VLBlockStandard;setRegistryName(Ljava/lang/String;Ljava/lang/String;)Lnet/minecraftforge/registries/IForgeRegistryEntry;"), index = 0) | ||
private String modifyRegistryName(String name) { | ||
if (blockName.equals("modifier_ember")) { | ||
return Embers.MODID; | ||
} | ||
return name; | ||
} | ||
|
||
@ModifyArg(method = "<init>(Ljava/lang/String;Lnet/minecraft/block/material/Material;)V", at = @At(value = "INVOKE", target = "Lcom/valkyrieofnight/vliblegacy/lib/block/adv/VLBlockStandard;setTranslationKey(Ljava/lang/String;)Lnet/minecraft/block/Block;"), index = 0) | ||
private String modifyTranslationKey(String name) { | ||
if (blockName.equals("modifier_ember")) { | ||
return Embers.MODID + "." + blockName; | ||
} | ||
return name; | ||
} | ||
|
||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/embers/blockstates/modifier_ember.json
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,5 @@ | ||
{ | ||
"variants":{ | ||
"normal":{"model": "embers:modifier_ember"} | ||
} | ||
} |
Oops, something went wrong.