Clean up code
This commit is contained in:
parent
e2cfd1d656
commit
dd228acf79
@ -1,5 +1,8 @@
|
||||
### Changelog
|
||||
|
||||
**1.0.5**
|
||||
* Clean up code
|
||||
|
||||
**1.0.4**
|
||||
* Migrate old worlds to new ID system
|
||||
|
||||
|
11
README.md
11
README.md
@ -29,7 +29,7 @@ You can apply Spells to blank or existing Spells in the Casting Table. Doing so
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
#### Casting table
|
||||
#### Casting Table
|
||||
<table>
|
||||
<tr>
|
||||
<td>Lapis Lazuli</td>
|
||||
@ -59,3 +59,12 @@ You can apply Spells to blank or existing Spells in the Casting Table. Doing so
|
||||
| Steadfast | 1 | Prevents Spell from rebounding. |
|
||||
| Teleport | 2 | Teleports target to random location. |
|
||||
| Inward | 1 | Causes the Spell to target the player. If the Spell fails instead of rebounding, it will just do nothing. |
|
||||
|
||||
## ```/spell``` Command
|
||||
This command requires OP permissions.
|
||||
|
||||
#### ```/spell clear <player>```
|
||||
This command clears all known spells from the given player.
|
||||
|
||||
#### ```/spell list <player>```
|
||||
This lists all the spells the given player knows.
|
@ -7,7 +7,6 @@ compileJava {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version as Object
|
||||
group = project.maven_group as Object
|
||||
|
||||
|
@ -8,7 +8,7 @@ org.gradle.jvmargs = -Xmx1G
|
||||
loader_version = 0.7.8+build.184
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.4
|
||||
mod_version = 1.0.5
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = sorcerycraft
|
||||
|
||||
|
@ -139,8 +139,12 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
||||
|
||||
private static final SoundEvent SPELL_SOUND_EFFECT = SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE;
|
||||
|
||||
public static void playSpellSound(World world, BlockPos pos) {
|
||||
world.playSound(null, pos, SPELL_SOUND_EFFECT, SoundCategory.BLOCKS, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public static void playSpellSound(BlockPointer block) {
|
||||
block.getWorld().playSound(null, block.getBlockPos(), SPELL_SOUND_EFFECT, SoundCategory.BLOCKS, 1.0f, 1.0f);
|
||||
playSpellSound(block.getWorld(), block.getBlockPos());
|
||||
}
|
||||
|
||||
public static void playSpellSound(PlayerEntity player) {
|
||||
|
@ -16,10 +16,13 @@ import net.minecraft.inventory.CraftingResultInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class CastingTableContainer extends Container {
|
||||
private final Inventory inventory;
|
||||
@ -94,7 +97,7 @@ public class CastingTableContainer extends Container {
|
||||
player.addExperienceLevels(-spells[index].getXPCost());
|
||||
}
|
||||
|
||||
SorceryCraft.playSpellSound(player);
|
||||
context.run((BiConsumer<World, BlockPos>) SorceryCraft::playSpellSound);
|
||||
|
||||
CastingTableContainer.this.inventory.setInvStack(0, ItemStack.EMPTY);
|
||||
CastingTableContainer.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount());
|
||||
@ -133,9 +136,7 @@ public class CastingTableContainer extends Container {
|
||||
@Override
|
||||
public void close(PlayerEntity player) {
|
||||
super.close(player);
|
||||
context.run((world, blockPos) -> {
|
||||
dropInventory(player, world, inventory);
|
||||
});
|
||||
context.run((BiConsumer<World, BlockPos>) (world, blockPos) -> dropInventory(player, world, inventory));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,11 +10,13 @@ import net.fabricmc.api.Environment;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
@ -58,7 +60,10 @@ public class SpellEntity extends ThrownItemEntity {
|
||||
if (success) {
|
||||
spell.execute(entity, this, getOwner());
|
||||
} else if (getOwner() != null) {
|
||||
getOwner().playSound(SoundEvents.ENCHANT_THORNS_HIT, 1.0f, 1.0f);
|
||||
if (getOwner() instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) getOwner();
|
||||
player.playSound(SoundEvents.ENCHANT_THORNS_HIT, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
||||
}
|
||||
spell.execute(getOwner(), this, getOwner());
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,6 @@ public class SpellItem extends Item {
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
|
||||
ItemStack itemStack = playerEntity.getStackInHand(hand);
|
||||
|
||||
Map<Identifier, Integer> spells = SpellTag.getSpells(itemStack);
|
||||
|
||||
if (spells.size() > 0) {
|
||||
SorceryCraft.playSpellSound(playerEntity);
|
||||
|
||||
if (!world.isClient()) {
|
||||
@ -54,9 +51,6 @@ public class SpellItem extends Item {
|
||||
}
|
||||
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, itemStack);
|
||||
} else {
|
||||
return new TypedActionResult<>(ActionResult.FAIL, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,7 +118,6 @@ public class SpellItem extends Item {
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
//LearnedNewSpellS2CPacket.send((ServerPlayerEntity) player);
|
||||
SorceryCraft.playSpellSound(player);
|
||||
spellPlayer.setSpells(playerSpells);
|
||||
}
|
||||
|
Reference in New Issue
Block a user