-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de8069f
commit bd24b17
Showing
23 changed files
with
143 additions
and
31 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
21 changes: 21 additions & 0 deletions
21
...va/cool/furry/mc/forge/projectexpansion/enchantments/EnchantmentAlchemicalCollection.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,21 @@ | ||
package cool.furry.mc.forge.projectexpansion.enchantments; | ||
|
||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.enchantment.EnchantmentType; | ||
import net.minecraft.inventory.EquipmentSlotType; | ||
|
||
public class EnchantmentAlchemicalCollection extends Enchantment { | ||
public EnchantmentAlchemicalCollection() { | ||
super(Rarity.RARE, EnchantmentType.DIGGER, new EquipmentSlotType[]{EquipmentSlotType.MAINHAND}); | ||
} | ||
|
||
@Override | ||
public int getMinEnchantability(int level) { | ||
return 15; | ||
} | ||
|
||
@Override | ||
public int getMaxEnchantability(int level) { | ||
return super.getMinEnchantability(level) + 50; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/cool/furry/mc/forge/projectexpansion/enchantments/package-info.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,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package cool.furry.mc.forge.projectexpansion.enchantments; | ||
|
||
import mcp.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
7 changes: 0 additions & 7 deletions
7
src/main/java/cool/furry/mc/forge/projectexpansion/init/package-info.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
src/main/java/cool/furry/mc/forge/projectexpansion/mixin/EnchantmentMixin.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,63 @@ | ||
package cool.furry.mc.forge.projectexpansion.mixin; | ||
|
||
import cool.furry.mc.forge.projectexpansion.registries.Enchantments; | ||
import moze_intel.projecte.api.ProjectEAPI; | ||
import moze_intel.projecte.api.capabilities.IKnowledgeProvider; | ||
import moze_intel.projecte.api.proxy.IEMCProxy; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.ServerPlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.SoundEvents; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.server.ServerWorld; | ||
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; | ||
|
||
import java.math.BigInteger; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
import java.util.stream.Collectors; | ||
|
||
@Mixin(Block.class) | ||
public abstract class EnchantmentMixin { | ||
@Inject(at = @At("RETURN"), method = "func_220077_a(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/item/ItemStack;)Ljava/util/List;", cancellable = true) | ||
private static void getDrops(BlockState state, ServerWorld world, BlockPos pos, TileEntity tileEntity, Entity entity, ItemStack stack, CallbackInfoReturnable<List<ItemStack>> cir) { | ||
if(!(entity instanceof ServerPlayerEntity)) return; | ||
ServerPlayerEntity player = (ServerPlayerEntity) entity; | ||
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(player.getUniqueID()); | ||
IEMCProxy proxy = ProjectEAPI.getEMCProxy(); | ||
assert Enchantments.ALCHEMICAL_COLLECTION.get() != null; | ||
boolean hasEnch = EnchantmentHelper.getEnchantmentLevel(Enchantments.ALCHEMICAL_COLLECTION.get(), stack) > 0; | ||
if(!state.canHarvestBlock(world, pos, player) || !hasEnch) return; | ||
List<ItemStack> initialDrops = cir.getReturnValue(); | ||
AtomicLong addEMC = new AtomicLong(); | ||
List<ItemStack> knowledgeAdditions = new ArrayList<>(); | ||
List<ItemStack> newDrops = initialDrops.stream() | ||
.map(drop -> { | ||
if(proxy.hasValue(drop)) { | ||
addEMC.addAndGet(proxy.getValue(drop)); | ||
if(!provider.hasKnowledge(drop)) knowledgeAdditions.add(drop); | ||
return null; | ||
} else return drop; | ||
}) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.toList()); | ||
|
||
if (newDrops.size() < initialDrops.size() || addEMC.get() > 0) { | ||
provider.setEmc(provider.getEmc().add(BigInteger.valueOf(addEMC.get()))); | ||
if(knowledgeAdditions.size() > 0) knowledgeAdditions.forEach(provider::addKnowledge); | ||
provider.sync(player); | ||
world.playSound(null, pos, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS, 1f, 0.75f); | ||
cir.setReturnValue(newDrops); | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...c/forge/projectexpansion/init/Blocks.java → ...e/projectexpansion/registries/Blocks.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
16 changes: 16 additions & 0 deletions
16
src/main/java/cool/furry/mc/forge/projectexpansion/registries/Enchantments.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,16 @@ | ||
package cool.furry.mc.forge.projectexpansion.registries; | ||
|
||
import cool.furry.mc.forge.projectexpansion.Main; | ||
import cool.furry.mc.forge.projectexpansion.enchantments.EnchantmentAlchemicalCollection; | ||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraftforge.fml.RegistryObject; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
@SuppressWarnings("unused") | ||
public class Enchantments { | ||
public static final DeferredRegister<Enchantment> Registry = new DeferredRegister<>(ForgeRegistries.ENCHANTMENTS, Main.MOD_ID); | ||
|
||
public static final RegistryObject<EnchantmentAlchemicalCollection> ALCHEMICAL_COLLECTION = Registry.register("alchemical_collection", EnchantmentAlchemicalCollection::new); | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
...mc/forge/projectexpansion/init/Items.java → ...ge/projectexpansion/registries/Items.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
2 changes: 1 addition & 1 deletion
2
...rojectexpansion/init/TileEntityTypes.java → ...expansion/registries/TileEntityTypes.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
7 changes: 7 additions & 0 deletions
7
src/main/java/cool/furry/mc/forge/projectexpansion/registries/package-info.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,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package cool.furry.mc.forge.projectexpansion.registries; | ||
|
||
import mcp.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
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
2 changes: 1 addition & 1 deletion
2
src/main/java/cool/furry/mc/forge/projectexpansion/tile/TileRelay.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
2 changes: 1 addition & 1 deletion
2
src/main/java/cool/furry/mc/forge/projectexpansion/tile/TileTransmutationInterface.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
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
4 changes: 2 additions & 2 deletions
4
src/main/java/cool/furry/mc/forge/projectexpansion/util/Fuel.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/cool/furry/mc/forge/projectexpansion/util/Star.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
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