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
5730a79
commit b47647b
Showing
5 changed files
with
151 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
72 changes: 72 additions & 0 deletions
72
src/main/java/de/melanx/maledicta/api/ApplyItemCurseEvent.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,72 @@ | ||
package de.melanx.maledicta.api; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraftforge.eventbus.api.Event; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* The event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} whenever an item could get | ||
* a new curse due to negative energy. The event is cancelable, if canceled, the curse won't be applied. The event | ||
* does not have a result. | ||
*/ | ||
public class ApplyItemCurseEvent extends Event { | ||
|
||
private final Player player; | ||
private final ItemStack stack; | ||
|
||
@Nullable | ||
private Enchantment enchantment; | ||
private boolean force; | ||
|
||
public ApplyItemCurseEvent(Player player, ItemStack stack, @Nullable Enchantment enchantment) { | ||
this.player = player; | ||
this.stack = stack; | ||
this.enchantment = enchantment; | ||
this.force = false; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
|
||
public ItemStack getStack() { | ||
return stack; | ||
} | ||
|
||
/** | ||
* Gets the enchantment that will be applied. | ||
*/ | ||
@Nullable | ||
public Enchantment getEnchantment() { | ||
return enchantment; | ||
} | ||
|
||
/** | ||
* Gets whether the enchantment is forced (will be applied even if it does not match the ItemStack) | ||
*/ | ||
public boolean isForced() { | ||
return force; | ||
} | ||
|
||
/** | ||
* Sets the enchantment that will be applied. | ||
*/ | ||
public void setEnchantment(@Nullable Enchantment enchantment) { | ||
this.enchantment = enchantment; | ||
} | ||
|
||
/** | ||
* Sets whether the enchantment is forced (will be applied even if it does not match the ItemStack) | ||
*/ | ||
public void setForced(boolean force) { | ||
this.force = force; | ||
} | ||
|
||
@Override | ||
public boolean isCancelable() { | ||
return true; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/de/melanx/maledicta/api/MaledictusAuferoEvent.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 de.melanx.maledicta.api; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.item.ItemEntity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraftforge.eventbus.api.Event; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} whenever a lightning bolt | ||
* hits a maledictus aufero. The event is cancelable, if canceled the maledictus aufero won't have any effects on | ||
* the nearby items. The event does not have a result. | ||
*/ | ||
public class MaledictusAuferoEvent extends Event { | ||
|
||
private final Level level; | ||
private final BlockState state; | ||
private final BlockPos pos; | ||
private final List<ItemEntity> allItems; | ||
private final List<ItemEntity> cursedItems; | ||
|
||
public MaledictusAuferoEvent(Level level, BlockState state, BlockPos pos, List<ItemEntity> allItems, List<ItemEntity> cursedItems) { | ||
this.level = level; | ||
this.state = state; | ||
this.pos = pos.immutable(); | ||
this.allItems = List.copyOf(allItems); | ||
this.cursedItems = List.copyOf(cursedItems); | ||
} | ||
|
||
public Level getLevel() { | ||
return level; | ||
} | ||
|
||
public BlockState getState() { | ||
return state; | ||
} | ||
|
||
public BlockPos getPos() { | ||
return pos; | ||
} | ||
|
||
/** | ||
* Gets all items in range of the maledictus aufero. These will get their negative energy halved | ||
* and may be enchanted with curses from other items if applicable. | ||
*/ | ||
public List<ItemEntity> getAllItems() { | ||
return allItems; | ||
} | ||
|
||
/** | ||
* Gets all the cursed items. These will get a curse removed (that may be put onto a different item if applicable). | ||
*/ | ||
public List<ItemEntity> getCursedItems() { | ||
return cursedItems; | ||
} | ||
|
||
@Override | ||
public boolean isCancelable() { | ||
return true; | ||
} | ||
} |
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