mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Fixed indentations because I'm tired of coming across these in my commits...
This commit is contained in:
parent
9abc072d7c
commit
0fd12b7ac1
42 changed files with 1590 additions and 1586 deletions
|
@ -12,21 +12,21 @@ import net.minecraft.client.renderer.BufferBuilder;
|
|||
|
||||
public class ModelQuads extends Box<ModelRenderer> {
|
||||
|
||||
public ModelQuads(ModelRenderer renderer) {
|
||||
super(renderer, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public ModelQuads(ModelRenderer renderer) {
|
||||
super(renderer, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
protected List<TexturedQuad> quadList = new ArrayList<TexturedQuad>();
|
||||
protected List<TexturedQuad> quadList = new ArrayList<TexturedQuad>();
|
||||
|
||||
public ModelQuads addFace(PositionTextureVertex... vertices) {
|
||||
quadList.add(new TexturedShape2d(vertices));
|
||||
public ModelQuads addFace(PositionTextureVertex... vertices) {
|
||||
quadList.add(new TexturedShape2d(vertices));
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void render(BufferBuilder renderer, float scale) {
|
||||
for (TexturedQuad i : quadList) {
|
||||
i.draw(renderer, scale);
|
||||
public void render(BufferBuilder renderer, float scale) {
|
||||
for (TexturedQuad i : quadList) {
|
||||
i.draw(renderer, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,23 +9,23 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
public class TexturedShape2d extends TexturedQuad {
|
||||
|
||||
protected boolean invertNormal;
|
||||
protected boolean invertNormal;
|
||||
|
||||
public TexturedShape2d(PositionTextureVertex... vertices) {
|
||||
super(vertices);
|
||||
}
|
||||
public TexturedShape2d(PositionTextureVertex... vertices) {
|
||||
super(vertices);
|
||||
}
|
||||
|
||||
public TexturedShape2d(PositionTextureVertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) {
|
||||
super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight);
|
||||
}
|
||||
public TexturedShape2d(PositionTextureVertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) {
|
||||
super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight);
|
||||
}
|
||||
|
||||
public TexturedShape2d setInvertNormal() {
|
||||
invertNormal = true;
|
||||
return this;
|
||||
}
|
||||
public TexturedShape2d setInvertNormal() {
|
||||
invertNormal = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void drawQuad(BufferBuilder renderer, float scale) {
|
||||
Vec3d vec3d = vertexPositions[1].vector3D.subtractReverse(vertexPositions[0].vector3D);
|
||||
public void drawQuad(BufferBuilder renderer, float scale) {
|
||||
Vec3d vec3d = vertexPositions[1].vector3D.subtractReverse(vertexPositions[0].vector3D);
|
||||
Vec3d vec3d1 = vertexPositions[1].vector3D.subtractReverse(vertexPositions[2].vector3D);
|
||||
Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize();
|
||||
float f = (float)vec3d2.x;
|
||||
|
@ -46,5 +46,5 @@ public class TexturedShape2d extends TexturedQuad {
|
|||
}
|
||||
|
||||
Tessellator.getInstance().draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,22 +30,22 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
||||
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
|
||||
public BlockCloud(Material material, String domain, String name) {
|
||||
super(material);
|
||||
setRegistryName(domain, name);
|
||||
public BlockCloud(Material material, String domain, String name) {
|
||||
super(material);
|
||||
setRegistryName(domain, name);
|
||||
setTranslationKey(name);
|
||||
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
setHardness(0.5f);
|
||||
setResistance(1.0F);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
setHardness(0.5f);
|
||||
setResistance(1.0F);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,11 +117,11 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
||||
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
||||
if (!applyBouncyness(state, entity)) {
|
||||
super.onEntityCollision(w, pos, state, entity);
|
||||
super.onEntityCollision(w, pos, state, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
|
||||
|
@ -130,9 +130,9 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
|
||||
@Deprecated
|
||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
|
||||
if (getCanInteract(state, entity)) {
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
}
|
||||
if (getCanInteract(state, entity)) {
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -144,29 +144,29 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return ((CloudType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (CloudType i : CloudType.values()) {
|
||||
list.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
list.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(VARIANT, CloudType.byMetadata(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return ((CloudType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, VARIANT);
|
||||
}
|
||||
|
|
|
@ -33,25 +33,25 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
||||
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
|
||||
private boolean isDouble;
|
||||
private boolean isDouble;
|
||||
|
||||
public BlockCloudSlab(boolean isDouble, Material material, String domain, String name) {
|
||||
super(material);
|
||||
public BlockCloudSlab(boolean isDouble, Material material, String domain, String name) {
|
||||
super(material);
|
||||
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setHardness(0.5F);
|
||||
setResistance(1.0F);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
this.isDouble = isDouble;
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setHardness(0.5F);
|
||||
setResistance(1.0F);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
this.isDouble = isDouble;
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return UBlocks.cloud.isTranslucent(state);
|
||||
}
|
||||
|
@ -61,22 +61,22 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
return allowsFallingBlockToPass(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isOpaqueCube(state) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isFullCube(state) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isNormalCube(state) : false;
|
||||
return isDouble() ? UBlocks.cloud.isNormalCube(state) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return UBlocks.cloud.getRenderLayer();
|
||||
}
|
||||
|
@ -88,25 +88,25 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
|
||||
@Override
|
||||
public void onFallenUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
||||
UBlocks.cloud.onFallenUpon(w, pos, entity, fallDistance);
|
||||
UBlocks.cloud.onFallenUpon(w, pos, entity, fallDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLanded(World w, Entity entity) {
|
||||
UBlocks.cloud.onLanded(w, entity);
|
||||
UBlocks.cloud.onLanded(w, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
||||
UBlocks.cloud.onEntityCollision(w, pos, state, entity);
|
||||
UBlocks.cloud.onEntityCollision(w, pos, state, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
|
||||
if (getCanInteract(state, entity)) {
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
}
|
||||
if (getCanInteract(state, entity)) {
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -232,12 +232,12 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return isDouble;
|
||||
}
|
||||
public boolean isDouble() {
|
||||
return isDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparable<CloudType> getTypeForItem(ItemStack stack) {
|
||||
return CloudType.byMetadata(stack.getMetadata() & 7);
|
||||
}
|
||||
@Override
|
||||
public Comparable<CloudType> getTypeForItem(ItemStack stack) {
|
||||
return CloudType.byMetadata(stack.getMetadata() & 7);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,46 +24,46 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockCloudStairs extends BlockStairs implements ICloudBlock {
|
||||
|
||||
protected Block theBlock;
|
||||
protected IBlockState theState;
|
||||
protected Block theBlock;
|
||||
protected IBlockState theState;
|
||||
|
||||
public BlockCloudStairs(IBlockState inherited, String domain, String name) {
|
||||
super(inherited);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
theBlock = inherited.getBlock();
|
||||
theState = inherited;
|
||||
useNeighborBrightness = true;
|
||||
public BlockCloudStairs(IBlockState inherited, String domain, String name) {
|
||||
super(inherited);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
theBlock = inherited.getBlock();
|
||||
theState = inherited;
|
||||
useNeighborBrightness = true;
|
||||
|
||||
fullBlock = isOpaqueCube(inherited);
|
||||
}
|
||||
fullBlock = isOpaqueCube(inherited);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return theBlock.isTranslucent(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return theBlock.isNormalCube(state);
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return theBlock.isNormalCube(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
|
||||
return theBlock.isPassable(worldIn, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onFallenUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
||||
theBlock.onFallenUpon(w, pos, entity, fallDistance);
|
||||
theBlock.onFallenUpon(w, pos, entity, fallDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,25 +71,25 @@ public class BlockCloudStairs extends BlockStairs implements ICloudBlock {
|
|||
return allowsFallingBlockToPass(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onLanded(World w, Entity entity) {
|
||||
theBlock.onLanded(w, entity);
|
||||
theBlock.onLanded(w, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
||||
theBlock.onEntityCollision(w, pos, theState, entity);
|
||||
}
|
||||
theBlock.onEntityCollision(w, pos, theState, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalk(World w, BlockPos pos, Entity entity) {
|
||||
theBlock.onEntityWalk(w, pos, entity);
|
||||
}
|
||||
@Override
|
||||
public void onEntityWalk(World w, BlockPos pos, Entity entity) {
|
||||
theBlock.onEntityWalk(w, pos, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
|
||||
@Override
|
||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
|
||||
if (getCanInteract(theState, entity)) {
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.block;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IColourful {
|
||||
int getCustomTint(IBlockState state, int tint);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
import net.minecraft.world.GameType;
|
||||
|
||||
class CommandOverrideGameMode extends CommandGameMode {
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException {
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException {
|
||||
if (params.length <= 0) {
|
||||
throw new WrongUsageException("commands.gamemode.usage");
|
||||
throw new WrongUsageException("commands.gamemode.usage");
|
||||
}
|
||||
|
||||
GameType gametype = getGameModeFromCommand(sender, params[0]);
|
||||
|
@ -27,22 +27,22 @@ class CommandOverrideGameMode extends CommandGameMode {
|
|||
ITextComponent chatcomponenttranslation = new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0]);
|
||||
|
||||
if (entityplayermp != sender) {
|
||||
notifyCommandListener(sender, this, 1, "commands.gamemode.success.other", entityplayermp.getName(), chatcomponenttranslation);
|
||||
notifyCommandListener(sender, this, 1, "commands.gamemode.success.other", entityplayermp.getName(), chatcomponenttranslation);
|
||||
} else {
|
||||
notifyCommandListener(sender, this, 1, "commands.gamemode.success.self", chatcomponenttranslation);
|
||||
notifyCommandListener(sender, this, 1, "commands.gamemode.success.self", chatcomponenttranslation);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGameMode(EntityPlayerMP player, GameType m) {
|
||||
boolean flying = player.capabilities.isFlying;
|
||||
private void updateGameMode(EntityPlayerMP player, GameType m) {
|
||||
boolean flying = player.capabilities.isFlying;
|
||||
|
||||
player.setGameType(m);
|
||||
player.capabilities.isFlying = PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies().canFly();
|
||||
player.setGameType(m);
|
||||
player.capabilities.isFlying = PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies().canFly();
|
||||
|
||||
if (flying != player.capabilities.isFlying) {
|
||||
player.sendPlayerAbilities();
|
||||
}
|
||||
if (flying != player.capabilities.isFlying) {
|
||||
player.sendPlayerAbilities();
|
||||
}
|
||||
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ import net.minecraft.util.text.TextFormatting;
|
|||
|
||||
class CommandRacelist extends CommandBase {
|
||||
|
||||
public String getName() {
|
||||
return "racelist";
|
||||
}
|
||||
public String getName() {
|
||||
return "racelist";
|
||||
}
|
||||
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public String getUsage(ICommandSender sender) {
|
||||
return "commands.racelist.usage";
|
||||
}
|
||||
public String getUsage(ICommandSender sender) {
|
||||
return "commands.racelist.usage";
|
||||
}
|
||||
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length < 2) {
|
||||
throw new WrongUsageException(getUsage(sender));
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class CommandRacelist extends CommandBase {
|
|||
} else {
|
||||
throw new WrongUsageException(getUsage(sender));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the strings available in this command to the given list of tab completion options.
|
||||
|
|
|
@ -21,9 +21,9 @@ import net.minecraft.util.text.TextFormatting;
|
|||
|
||||
class CommandSpecies extends CommandBase {
|
||||
|
||||
public String getName() {
|
||||
return "race";
|
||||
}
|
||||
public String getName() {
|
||||
return "race";
|
||||
}
|
||||
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
|
@ -34,89 +34,89 @@ class CommandSpecies extends CommandBase {
|
|||
}
|
||||
|
||||
private String getRacesString() {
|
||||
String values = "";
|
||||
String values = "";
|
||||
|
||||
return values;
|
||||
return values;
|
||||
}
|
||||
|
||||
public String getUsage(ICommandSender sender) {
|
||||
return "commands.race.usage";
|
||||
}
|
||||
public String getUsage(ICommandSender sender) {
|
||||
return "commands.race.usage";
|
||||
}
|
||||
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length < 1) {
|
||||
throw new WrongUsageException(getUsage(sender));
|
||||
}
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length < 1) {
|
||||
throw new WrongUsageException(getUsage(sender));
|
||||
}
|
||||
|
||||
EntityPlayerMP player;
|
||||
int playerIndex = 1;
|
||||
EntityPlayerMP player;
|
||||
int playerIndex = 1;
|
||||
|
||||
if (args[0].contentEquals("set") || args[0].contentEquals("describe")) {
|
||||
playerIndex++;
|
||||
}
|
||||
if (args[0].contentEquals("set") || args[0].contentEquals("describe")) {
|
||||
playerIndex++;
|
||||
}
|
||||
|
||||
if (args.length > playerIndex) {
|
||||
player = getPlayer(server, sender, args[playerIndex]);
|
||||
} else {
|
||||
player = getCommandSenderAsPlayer(sender);
|
||||
}
|
||||
if (args.length > playerIndex) {
|
||||
player = getPlayer(server, sender, args[playerIndex]);
|
||||
} else {
|
||||
player = getCommandSenderAsPlayer(sender);
|
||||
}
|
||||
|
||||
if (args[0].contentEquals("set") && args.length >= 2) {
|
||||
Race species = Race.fromName(args[1], Race.HUMAN);
|
||||
if (args[0].contentEquals("set") && args.length >= 2) {
|
||||
Race species = Race.fromName(args[1], Race.HUMAN);
|
||||
|
||||
if (species.isDefault()) {
|
||||
ITextComponent message = new TextComponentTranslation("commands.race.fail", args[1].toUpperCase());
|
||||
message.getStyle().setColor(TextFormatting.RED);
|
||||
if (species.isDefault()) {
|
||||
ITextComponent message = new TextComponentTranslation("commands.race.fail", args[1].toUpperCase());
|
||||
message.getStyle().setColor(TextFormatting.RED);
|
||||
|
||||
player.sendMessage(message);
|
||||
} else {
|
||||
if (PlayerSpeciesList.instance().speciesPermitted(species, player)) {
|
||||
PlayerSpeciesList.instance().getPlayer(player).setPlayerSpecies(species);
|
||||
player.sendMessage(message);
|
||||
} else {
|
||||
if (PlayerSpeciesList.instance().speciesPermitted(species, player)) {
|
||||
PlayerSpeciesList.instance().getPlayer(player).setPlayerSpecies(species);
|
||||
|
||||
ITextComponent formattedName = new TextComponentTranslation(species.name().toLowerCase());
|
||||
ITextComponent formattedName = new TextComponentTranslation(species.name().toLowerCase());
|
||||
|
||||
if (player != sender) {
|
||||
notifyCommandListener(sender, this, 1, "commands.race.success.other", player.getName(), formattedName);
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.success.self"));
|
||||
notifyCommandListener(sender, this, 1, "commands.race.success.otherself", player.getName(), formattedName);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.permission"));
|
||||
}
|
||||
}
|
||||
} else if (args[0].contentEquals("get")) {
|
||||
Race spec = PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies();
|
||||
if (player != sender) {
|
||||
notifyCommandListener(sender, this, 1, "commands.race.success.other", player.getName(), formattedName);
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.success.self"));
|
||||
notifyCommandListener(sender, this, 1, "commands.race.success.otherself", player.getName(), formattedName);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.permission"));
|
||||
}
|
||||
}
|
||||
} else if (args[0].contentEquals("get")) {
|
||||
Race spec = PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies();
|
||||
|
||||
String name = "commands.race.tell.";
|
||||
name += player == sender ? "self" : "other";
|
||||
String name = "commands.race.tell.";
|
||||
name += player == sender ? "self" : "other";
|
||||
|
||||
ITextComponent race = new TextComponentTranslation(spec.getTranslationKey());
|
||||
ITextComponent message = new TextComponentTranslation(name);
|
||||
ITextComponent race = new TextComponentTranslation(spec.getTranslationKey());
|
||||
ITextComponent message = new TextComponentTranslation(name);
|
||||
|
||||
race.getStyle().setColor(TextFormatting.GOLD);
|
||||
race.getStyle().setColor(TextFormatting.GOLD);
|
||||
|
||||
message.appendSibling(race);
|
||||
message.appendSibling(race);
|
||||
|
||||
player.sendMessage(message);
|
||||
} else if (args[0].contentEquals("list")) {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.list"));
|
||||
player.sendMessage(message);
|
||||
} else if (args[0].contentEquals("list")) {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.list"));
|
||||
|
||||
ITextComponent message = new TextComponentString(getRacesString());
|
||||
ITextComponent message = new TextComponentString(getRacesString());
|
||||
|
||||
boolean first = true;
|
||||
for (Race i : Race.values()) {
|
||||
if (!i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player)) {
|
||||
message.appendSibling(new TextComponentString((!first ? "\n" : "") + " - " + i.name().toLowerCase()));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
boolean first = true;
|
||||
for (Race i : Race.values()) {
|
||||
if (!i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player)) {
|
||||
message.appendSibling(new TextComponentString((!first ? "\n" : "") + " - " + i.name().toLowerCase()));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
message.getStyle().setColor(TextFormatting.GOLD);
|
||||
message.getStyle().setColor(TextFormatting.GOLD);
|
||||
|
||||
player.sendMessage(message);
|
||||
} else if (args[0].contentEquals("describe") && args.length >= 2) {
|
||||
Race species = Race.fromName(args[1], null);
|
||||
player.sendMessage(message);
|
||||
} else if (args[0].contentEquals("describe") && args.length >= 2) {
|
||||
Race species = Race.fromName(args[1], null);
|
||||
|
||||
if (species == null) {
|
||||
player.sendMessage(new TextComponentTranslation("commands.race.fail", args[1].toUpperCase()));
|
||||
|
@ -135,47 +135,47 @@ class CommandSpecies extends CommandBase {
|
|||
|
||||
player.sendMessage(line3);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
throw new WrongUsageException(getUsage(sender));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the strings available in this command to the given list of tab completion options.
|
||||
*/
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) {
|
||||
|
||||
if (args.length == 1) {
|
||||
return getListOfStringsMatchingLastWord(args, "get", "set", "list", "describe");
|
||||
}
|
||||
if (args.length == 1) {
|
||||
return getListOfStringsMatchingLastWord(args, "get", "set", "list", "describe");
|
||||
}
|
||||
|
||||
if (args.length == 2 && (args[0].contentEquals("set") || args[0].contentEquals("describe"))) {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
if (args.length == 2 && (args[0].contentEquals("set") || args[0].contentEquals("describe"))) {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
EntityPlayer player = sender instanceof EntityPlayer ? (EntityPlayer)sender : null;
|
||||
EntityPlayer player = sender instanceof EntityPlayer ? (EntityPlayer)sender : null;
|
||||
|
||||
for (Race i : Race.values()) {
|
||||
if (args[0].contentEquals("describe") || !(i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player))) {
|
||||
names.add(i.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
for (Race i : Race.values()) {
|
||||
if (args[0].contentEquals("describe") || !(i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player))) {
|
||||
names.add(i.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return getListOfStringsMatchingLastWord(args, names.stream().toArray(String[]::new));
|
||||
}
|
||||
return getListOfStringsMatchingLastWord(args, names.stream().toArray(String[]::new));
|
||||
}
|
||||
|
||||
if ((args.length == 3 && args[0].contentEquals("set")) || (args[0].contentEquals("get") && args.length == 2)) {
|
||||
return getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames());
|
||||
}
|
||||
if ((args.length == 3 && args[0].contentEquals("set")) || (args[0].contentEquals("get") && args.length == 2)) {
|
||||
return getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isUsernameIndex(String[] args, int index) {
|
||||
if (args[0].contentEquals("get")) {
|
||||
return index == 1;
|
||||
} else if (args[0].contentEquals("set")) {
|
||||
return index == 2;
|
||||
}
|
||||
if (args[0].contentEquals("get")) {
|
||||
return index == 1;
|
||||
} else if (args[0].contentEquals("set")) {
|
||||
return index == 2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,19 +27,19 @@ public class EntitySpellbook extends EntityLiving implements IMagicals {
|
|||
private static final DataParameter<Boolean> OPENED = EntityDataManager.createKey(EntitySpellbook.class, DataSerializers.BOOLEAN);
|
||||
private static final DataParameter<Byte> OPENED_USER = EntityDataManager.createKey(EntitySpellbook.class, DataSerializers.BYTE);
|
||||
|
||||
public EntitySpellbook(World worldIn) {
|
||||
super(worldIn);
|
||||
setSize(0.6f, 0.6f);
|
||||
}
|
||||
public EntitySpellbook(World worldIn) {
|
||||
super(worldIn);
|
||||
setSize(0.6f, 0.6f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
dataManager.register(OPENED, true);
|
||||
dataManager.register(OPENED_USER, (byte)1);
|
||||
}
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
dataManager.register(OPENED, true);
|
||||
dataManager.register(OPENED_USER, (byte)1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
@ -55,117 +55,117 @@ public class EntitySpellbook extends EntityLiving implements IMagicals {
|
|||
}
|
||||
|
||||
public boolean getIsOpen() {
|
||||
return dataManager.get(OPENED);
|
||||
return dataManager.get(OPENED);
|
||||
}
|
||||
|
||||
public Boolean getUserSetState() {
|
||||
byte state = dataManager.get(OPENED_USER);
|
||||
return state == 1 ? null : state == 2;
|
||||
byte state = dataManager.get(OPENED_USER);
|
||||
return state == 1 ? null : state == 2;
|
||||
}
|
||||
|
||||
public void setIsOpen(boolean val) {
|
||||
dataManager.set(OPENED, val);
|
||||
dataManager.set(OPENED, val);
|
||||
}
|
||||
|
||||
public void setUserSetState(Boolean val) {
|
||||
dataManager.set(OPENED_USER, val == null ? (byte)1 : val == true ? (byte)2 : (byte)0);
|
||||
dataManager.set(OPENED_USER, val == null ? (byte)1 : val == true ? (byte)2 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
boolean open = getIsOpen();
|
||||
this.isJumping = open && isInWater();
|
||||
super.onUpdate();
|
||||
if (open && world.isRemote) {
|
||||
for (int offX = -2; offX <= 1; ++offX) {
|
||||
for (int offZ = -2; offZ <= 1; ++offZ) {
|
||||
if (offX > -1 && offX < 1 && offZ == -1) offZ = 1;
|
||||
if (rand.nextInt(320) == 0) {
|
||||
for (int offY = 0; offY <= 1; ++offY) {
|
||||
float vX = (float)offX/2 + rand.nextFloat();
|
||||
float vY = (float)offY/2 - rand.nextFloat() + 0.5f;
|
||||
float vZ = (float)offZ/2 + rand.nextFloat();
|
||||
world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, posX, posY, posZ, vX, vY, vZ, new int[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean open = getIsOpen();
|
||||
this.isJumping = open && isInWater();
|
||||
super.onUpdate();
|
||||
if (open && world.isRemote) {
|
||||
for (int offX = -2; offX <= 1; ++offX) {
|
||||
for (int offZ = -2; offZ <= 1; ++offZ) {
|
||||
if (offX > -1 && offX < 1 && offZ == -1) offZ = 1;
|
||||
if (rand.nextInt(320) == 0) {
|
||||
for (int offY = 0; offY <= 1; ++offY) {
|
||||
float vX = (float)offX/2 + rand.nextFloat();
|
||||
float vY = (float)offY/2 - rand.nextFloat() + 0.5f;
|
||||
float vZ = (float)offZ/2 + rand.nextFloat();
|
||||
world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, posX, posY, posZ, vX, vY, vZ, new int[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(30) == 0) {
|
||||
float celest = world.getCelestialAngle(1) * 4;
|
||||
boolean isDay = celest > 3 || celest < 1;
|
||||
Boolean userState = getUserSetState();
|
||||
boolean canToggle = (isDay != open) && (userState == null || userState == isDay);
|
||||
if (canToggle) {
|
||||
setUserSetState(null);
|
||||
setIsOpen(isDay);
|
||||
}
|
||||
if (userState != null && (isDay == open) && (userState == open)) {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
if (world.rand.nextInt(30) == 0) {
|
||||
float celest = world.getCelestialAngle(1) * 4;
|
||||
boolean isDay = celest > 3 || celest < 1;
|
||||
Boolean userState = getUserSetState();
|
||||
boolean canToggle = (isDay != open) && (userState == null || userState == isDay);
|
||||
if (canToggle) {
|
||||
setUserSetState(null);
|
||||
setIsOpen(isDay);
|
||||
}
|
||||
if (userState != null && (isDay == open) && (userState == open)) {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (!world.isRemote) {
|
||||
setDead();
|
||||
SoundType sound = SoundType.WOOD;
|
||||
world.playSound(posX, posY, posZ, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
|
||||
if (world.getGameRules().getBoolean("doTileDrops")) {
|
||||
entityDropItem(new ItemStack(UItems.spellbook), 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (!world.isRemote) {
|
||||
setDead();
|
||||
SoundType sound = SoundType.WOOD;
|
||||
world.playSound(posX, posY, posZ, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
|
||||
if (world.getGameRules().getBoolean("doTileDrops")) {
|
||||
entityDropItem(new ItemStack(UItems.spellbook), 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
|
||||
if (player.isSneaking()) {
|
||||
boolean open = !getIsOpen();
|
||||
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
|
||||
if (player.isSneaking()) {
|
||||
boolean open = !getIsOpen();
|
||||
|
||||
setIsOpen(open);
|
||||
setUserSetState(open);
|
||||
setIsOpen(open);
|
||||
setUserSetState(open);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (Predicates.MAGI.test(player)) {
|
||||
if (Predicates.MAGI.test(player)) {
|
||||
|
||||
player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1);
|
||||
player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1);
|
||||
|
||||
player.openGui(Unicopia.MODID, 0, world, (int)posX, (int)posY, (int)posZ);
|
||||
player.openGui(Unicopia.MODID, 0, world, (int)posX, (int)posY, (int)posZ);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
setIsOpen(compound.getBoolean("open"));
|
||||
if (compound.hasKey("force_open")) {
|
||||
setUserSetState(compound.getBoolean("force_open"));
|
||||
} else {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
setIsOpen(compound.getBoolean("open"));
|
||||
if (compound.hasKey("force_open")) {
|
||||
setUserSetState(compound.getBoolean("force_open"));
|
||||
} else {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
compound.setBoolean("open", getIsOpen());
|
||||
Boolean state = getUserSetState();
|
||||
if (state != null) {
|
||||
compound.setBoolean("force_open", state);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
compound.setBoolean("open", getIsOpen());
|
||||
Boolean state = getUserSetState();
|
||||
if (state != null) {
|
||||
compound.setBoolean("force_open", state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickedResult(RayTraceResult target) {
|
||||
return new ItemStack(UItems.spellbook);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getPickedResult(RayTraceResult target) {
|
||||
return new ItemStack(UItems.spellbook);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ public class EntityWildCloud extends EntityCloud {
|
|||
public static final SpawnListEntry SPAWN_ENTRY_OCEAN = new SpawnListEntry(EntityWildCloud.class, 1, 1, 7);
|
||||
|
||||
public EntityWildCloud(World world) {
|
||||
super(world);
|
||||
super(world);
|
||||
|
||||
preventEntitySpawning = true;
|
||||
}
|
||||
preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotColliding() {
|
||||
AxisAlignedBB boundingbox = getEntityBoundingBox();
|
||||
|
||||
return checkNoEntityCollision(boundingbox, this)
|
||||
&& world.canBlockSeeSky(new BlockPos(this))
|
||||
&& world.getCollisionBoxes(this, boundingbox).isEmpty()
|
||||
&& !world.containsAnyLiquid(boundingbox);
|
||||
return checkNoEntityCollision(boundingbox, this)
|
||||
&& world.canBlockSeeSky(new BlockPos(this))
|
||||
&& world.getCollisionBoxes(this, boundingbox).isEmpty()
|
||||
&& !world.containsAnyLiquid(boundingbox);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +108,7 @@ public class EntityWildCloud extends EntityCloud {
|
|||
collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
return pack;
|
||||
return pack;
|
||||
}
|
||||
|
||||
static class PackData implements IEntityLivingData {
|
||||
|
|
|
@ -12,56 +12,56 @@ import net.minecraft.client.settings.KeyBinding;
|
|||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
class UKeyHandler implements IKeyHandler {
|
||||
private static ArrayList<KeyBinding> bindings = new ArrayList<KeyBinding>();
|
||||
private static ArrayList<KeyBinding> removed = new ArrayList<KeyBinding>();
|
||||
private static ArrayList<KeyBinding> bindings = new ArrayList<KeyBinding>();
|
||||
private static ArrayList<KeyBinding> removed = new ArrayList<KeyBinding>();
|
||||
|
||||
private static ArrayList<KeyBinding> pressed = new ArrayList<KeyBinding>();
|
||||
private static ArrayList<KeyBinding> pressed = new ArrayList<KeyBinding>();
|
||||
|
||||
@Override
|
||||
public void addKeybind(IKeyBind p) {
|
||||
KeyBinding b = new KeyBinding(p.getKeyName(), p.getKeyCode(), p.getKeyCategory());
|
||||
@Override
|
||||
public void addKeybind(IKeyBind p) {
|
||||
KeyBinding b = new KeyBinding(p.getKeyName(), p.getKeyCode(), p.getKeyCategory());
|
||||
|
||||
ClientRegistry.registerKeyBinding(b);
|
||||
ClientRegistry.registerKeyBinding(b);
|
||||
|
||||
bindings.add(b);
|
||||
}
|
||||
bindings.add(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyInput() {
|
||||
if (Minecraft.getMinecraft().currentScreen != null
|
||||
|| Minecraft.getMinecraft().player == null) {
|
||||
return;
|
||||
}
|
||||
IPlayer iplayer = PlayerSpeciesList.instance().getPlayer(Minecraft.getMinecraft().player);
|
||||
@Override
|
||||
public void onKeyInput() {
|
||||
if (Minecraft.getMinecraft().currentScreen != null
|
||||
|| Minecraft.getMinecraft().player == null) {
|
||||
return;
|
||||
}
|
||||
IPlayer iplayer = PlayerSpeciesList.instance().getPlayer(Minecraft.getMinecraft().player);
|
||||
|
||||
for (KeyBinding i : bindings) {
|
||||
if (GameSettings.isKeyDown(i)) {
|
||||
for (KeyBinding i : bindings) {
|
||||
if (GameSettings.isKeyDown(i)) {
|
||||
|
||||
if (!pressed.contains(i)) {
|
||||
pressed.add(i);
|
||||
if (!pressed.contains(i)) {
|
||||
pressed.add(i);
|
||||
|
||||
if (!PowersRegistry.instance().hasRegisteredPower(i.getKeyCodeDefault())) {
|
||||
removed.add(i);
|
||||
System.out.println("Error: Keybinding(" + i.getKeyDescription() + ") does not have a registered pony power. Keybinding will be removed from event.");
|
||||
} else {
|
||||
PowersRegistry.instance()
|
||||
.getCapablePowerFromKey(i.getKeyCodeDefault(), iplayer.getPlayerSpecies())
|
||||
.ifPresent(iplayer.getAbilities()::tryUseAbility);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pressed.contains(i)) {
|
||||
pressed.remove(i);
|
||||
if (!PowersRegistry.instance().hasRegisteredPower(i.getKeyCodeDefault())) {
|
||||
removed.add(i);
|
||||
System.out.println("Error: Keybinding(" + i.getKeyDescription() + ") does not have a registered pony power. Keybinding will be removed from event.");
|
||||
} else {
|
||||
PowersRegistry.instance()
|
||||
.getCapablePowerFromKey(i.getKeyCodeDefault(), iplayer.getPlayerSpecies())
|
||||
.ifPresent(iplayer.getAbilities()::tryUseAbility);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pressed.contains(i)) {
|
||||
pressed.remove(i);
|
||||
|
||||
iplayer.getAbilities().tryClearAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
iplayer.getAbilities().tryClearAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (KeyBinding i : removed) {
|
||||
removed.remove(i);
|
||||
bindings.remove(i);
|
||||
pressed.remove(i);
|
||||
}
|
||||
}
|
||||
for (KeyBinding i : removed) {
|
||||
removed.remove(i);
|
||||
bindings.remove(i);
|
||||
pressed.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.InventoryCrafting;
|
||||
|
||||
public class InventorySpellBook extends InventoryCrafting {
|
||||
|
||||
private final IInventory craftResult;
|
||||
|
||||
public InventorySpellBook(IInventory resultMatrix, Container eventHandler, int width, int height) {
|
||||
super(eventHandler, width, height);
|
||||
craftResult = resultMatrix;
|
||||
}
|
||||
|
||||
public IInventory getCraftResultMatrix() {
|
||||
return craftResult;
|
||||
}
|
||||
|
||||
private final IInventory craftResult;
|
||||
|
||||
public InventorySpellBook(IInventory resultMatrix, Container eventHandler, int width, int height) {
|
||||
super(eventHandler, width, height);
|
||||
craftResult = resultMatrix;
|
||||
}
|
||||
|
||||
public IInventory getCraftResultMatrix() {
|
||||
return craftResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,73 +25,73 @@ import net.minecraft.world.World;
|
|||
|
||||
public class ContainerSpellBook extends Container {
|
||||
|
||||
private final World worldObj;
|
||||
private final World worldObj;
|
||||
|
||||
private IInventory craftResult = new InventoryBasic("Spell Result", false, 1);
|
||||
private IInventory craftResult = new InventoryBasic("Spell Result", false, 1);
|
||||
|
||||
private InventorySpellBook craftMatrix = new InventorySpellBook(craftResult, this, 5, 1);
|
||||
private InventorySpellBook craftMatrix = new InventorySpellBook(craftResult, this, 5, 1);
|
||||
|
||||
private IPageUnlockListener listener;
|
||||
private IPageUnlockListener listener;
|
||||
|
||||
private SlotEnchantingResult resultSlot = null;
|
||||
private SlotEnchantingResult resultSlot = null;
|
||||
|
||||
private final EntityPlayer player;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public ContainerSpellBook(InventoryPlayer inventory, World world, BlockPos pos) {
|
||||
super();
|
||||
worldObj = world;
|
||||
player = inventory.player;
|
||||
public ContainerSpellBook(InventoryPlayer inventory, World world, BlockPos pos) {
|
||||
super();
|
||||
worldObj = world;
|
||||
player = inventory.player;
|
||||
|
||||
initCraftingSlots();
|
||||
initCraftingSlots();
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new Slot(inventory, i, 121 + i * 18, 195));
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
|
||||
public void setListener(IPageUnlockListener listener) {
|
||||
this.listener = listener;
|
||||
public void setListener(IPageUnlockListener listener) {
|
||||
this.listener = listener;
|
||||
|
||||
if (resultSlot != null) {
|
||||
resultSlot.setListener(listener);
|
||||
}
|
||||
}
|
||||
if (resultSlot != null) {
|
||||
resultSlot.setListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void initCraftingSlots() {
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 0, 180, 50));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 1, 154, 94));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 2, 180, 134));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 3, 231, 120));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 4, 232, 65));
|
||||
addSlotToContainer(resultSlot = new SlotEnchantingResult(listener, PlayerSpeciesList.instance().getPlayer(player), craftMatrix, craftResult, 0, 196, 92));
|
||||
}
|
||||
public void initCraftingSlots() {
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 0, 180, 50));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 1, 154, 94));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 2, 180, 134));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 3, 231, 120));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 4, 232, 65));
|
||||
addSlotToContainer(resultSlot = new SlotEnchantingResult(listener, PlayerSpeciesList.instance().getPlayer(player), craftMatrix, craftResult, 0, 196, 92));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventoryIn) {
|
||||
ItemStack current = craftResult.getStackInSlot(0);
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventoryIn) {
|
||||
ItemStack current = craftResult.getStackInSlot(0);
|
||||
|
||||
if (!current.isEmpty()) {
|
||||
ItemStack crafted = Unicopia.getCraftingManager().findMatchingResult(craftMatrix, worldObj);
|
||||
if (!current.isEmpty()) {
|
||||
ItemStack crafted = Unicopia.getCraftingManager().findMatchingResult(craftMatrix, worldObj);
|
||||
|
||||
if (!crafted.isEmpty()) {
|
||||
current = SpellRegistry.instance().enchantStack(current, crafted);
|
||||
if (!crafted.isEmpty()) {
|
||||
current = SpellRegistry.instance().enchantStack(current, crafted);
|
||||
|
||||
player.playSound(SoundEvents.BLOCK_NOTE_CHIME, 1, 1);
|
||||
} else {
|
||||
current = SpellRegistry.instance().disenchantStack(current);
|
||||
player.playSound(SoundEvents.BLOCK_NOTE_CHIME, 1, 1);
|
||||
} else {
|
||||
current = SpellRegistry.instance().disenchantStack(current);
|
||||
|
||||
player.playSound(SoundEvents.BLOCK_NOTE_BASS, 1, 1);
|
||||
}
|
||||
player.playSound(SoundEvents.BLOCK_NOTE_BASS, 1, 1);
|
||||
}
|
||||
|
||||
craftResult.setInventorySlotContents(0, current);
|
||||
}
|
||||
}
|
||||
craftResult.setInventorySlotContents(0, current);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
Slot slot = inventorySlots.get(index);
|
||||
|
||||
|
@ -126,25 +126,25 @@ public class ContainerSpellBook extends Container {
|
|||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
if (craftMatrix.getStackInSlot(i) != null) {
|
||||
player.dropItem(craftMatrix.getStackInSlot(i), false);
|
||||
craftMatrix.setInventorySlotContents(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
if (craftMatrix.getStackInSlot(i) != null) {
|
||||
player.dropItem(craftMatrix.getStackInSlot(i), false);
|
||||
craftMatrix.setInventorySlotContents(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
if (craftResult.getStackInSlot(0) != null) {
|
||||
player.dropItem(craftResult.getStackInSlot(0), false);
|
||||
craftResult.setInventorySlotContents(0, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
if (craftResult.getStackInSlot(0) != null) {
|
||||
player.dropItem(craftResult.getStackInSlot(0), false);
|
||||
craftResult.setInventorySlotContents(0, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return Predicates.MAGI.test(player);
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return Predicates.MAGI.test(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,35 +25,35 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
||||
|
||||
private static IPage currentIPage;
|
||||
private static IPage currentIPage;
|
||||
|
||||
private static final ResourceLocation spellBookGuiTextures = new ResourceLocation("unicopia", "textures/gui/container/book.png");
|
||||
private static final ResourceLocation spellBookGuiTextures = new ResourceLocation("unicopia", "textures/gui/container/book.png");
|
||||
|
||||
private IPlayer playerExtension;
|
||||
private IPlayer playerExtension;
|
||||
|
||||
|
||||
private PageButton nextPage;
|
||||
private PageButton prevPage;
|
||||
private PageButton nextPage;
|
||||
private PageButton prevPage;
|
||||
|
||||
public GuiSpellBook(EntityPlayer player) {
|
||||
super(new ContainerSpellBook(player.inventory, player.world, new BlockPos(player)));
|
||||
player.openContainer = inventorySlots;
|
||||
public GuiSpellBook(EntityPlayer player) {
|
||||
super(new ContainerSpellBook(player.inventory, player.world, new BlockPos(player)));
|
||||
player.openContainer = inventorySlots;
|
||||
|
||||
xSize = 405;
|
||||
xSize = 405;
|
||||
ySize = 219;
|
||||
allowUserInput = true;
|
||||
playerExtension = PlayerSpeciesList.instance().getPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
|
||||
int x = (width - xSize) / 2;
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
|
||||
buttonList.add(nextPage = new PageButton(1, x + 360, y + 160, true));
|
||||
buttonList.add(nextPage = new PageButton(1, x + 360, y + 160, true));
|
||||
buttonList.add(prevPage = new PageButton(2, x + 20, y + 160, false));
|
||||
|
||||
if (currentIPage == null) {
|
||||
|
@ -61,29 +61,29 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
}
|
||||
|
||||
onPageChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
initGui();
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
initGui();
|
||||
|
||||
if (button.id == 1) {
|
||||
currentIPage = currentIPage.next();
|
||||
} else {
|
||||
currentIPage = currentIPage.prev();
|
||||
}
|
||||
if (button.id == 1) {
|
||||
currentIPage = currentIPage.next();
|
||||
} else {
|
||||
currentIPage = currentIPage.prev();
|
||||
}
|
||||
|
||||
onPageChange();
|
||||
}
|
||||
onPageChange();
|
||||
}
|
||||
|
||||
protected void onPageChange() {
|
||||
protected void onPageChange() {
|
||||
prevPage.visible = currentIPage.getIndex() > 0;
|
||||
nextPage.visible = currentIPage.getIndex() < Pages.instance().getTotalPages() - 1;
|
||||
|
||||
if (playerExtension.getPageState(currentIPage) == PageState.UNREAD) {
|
||||
playerExtension.setPageState(currentIPage, PageState.READ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPageUnlocked(IPage page) {
|
||||
|
@ -100,44 +100,44 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGradientRect(int left, int top, int width, int height, int startColor, int endColor) {
|
||||
Slot slot = getSlotUnderMouse();
|
||||
if (slot == null || left != slot.xPos || top != slot.yPos || !drawSlotOverlay(slot)) {
|
||||
super.drawGradientRect(left, top, width, height, startColor, endColor);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void drawGradientRect(int left, int top, int width, int height, int startColor, int endColor) {
|
||||
Slot slot = getSlotUnderMouse();
|
||||
if (slot == null || left != slot.xPos || top != slot.yPos || !drawSlotOverlay(slot)) {
|
||||
super.drawGradientRect(left, top, width, height, startColor, endColor);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean drawSlotOverlay(Slot slot) {
|
||||
if (slot instanceof SlotEnchanting) {
|
||||
GlStateManager.enableBlend();
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(slot.xPos - 1, slot.yPos - 1, 51, 223, 18, 18, 512, 256);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GlStateManager.disableBlend();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected boolean drawSlotOverlay(Slot slot) {
|
||||
if (slot instanceof SlotEnchanting) {
|
||||
GlStateManager.enableBlend();
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(slot.xPos - 1, slot.yPos - 1, 51, 223, 18, 18, 512, 256);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GlStateManager.disableBlend();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
String text = String.format("%d / %d", currentIPage.getIndex() + 1, Pages.instance().getTotalPages());
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
String text = String.format("%d / %d", currentIPage.getIndex() + 1, Pages.instance().getTotalPages());
|
||||
|
||||
fontRenderer.drawString(text, 203 - fontRenderer.getStringWidth(text)/2, 165, 0x0);
|
||||
}
|
||||
fontRenderer.drawString(text, 203 - fontRenderer.getStringWidth(text)/2, 165, 0x0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
|
||||
int left = (width - xSize) / 2;
|
||||
int top = (height - ySize) / 2;
|
||||
|
@ -151,26 +151,26 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
if (playerExtension.getPageState(currentIPage) != PageState.LOCKED) {
|
||||
ResourceLocation texture = currentIPage.getTexture();
|
||||
|
||||
if (mc.getTextureManager().getTexture(texture) != TextureUtil.MISSING_TEXTURE) {
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (mc.getTextureManager().getTexture(texture) != TextureUtil.MISSING_TEXTURE) {
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
drawModalRectWithCustomSizedTexture(left, top, 0, 0, xSize, ySize, 512, 256);
|
||||
} else {
|
||||
if (playerExtension.getWorld().rand.nextInt(100) == 0) {
|
||||
Unicopia.log.fatal("Missing texture " + texture);
|
||||
}
|
||||
}
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
drawModalRectWithCustomSizedTexture(left, top, 0, 0, xSize, ySize, 512, 256);
|
||||
} else {
|
||||
if (playerExtension.getWorld().rand.nextInt(100) == 0) {
|
||||
Unicopia.log.fatal("Missing texture " + texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(left + 152, top + 49, 407, 2, 100, 101, 512, 256);
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
static class PageButton extends GuiButton {
|
||||
static class PageButton extends GuiButton {
|
||||
private final boolean direction;
|
||||
|
||||
private int shakesLeft = 0;
|
||||
|
@ -184,17 +184,17 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
||||
if (visible) {
|
||||
int x = this.x;
|
||||
int y = this.y;
|
||||
if (shakesLeft > 0) {
|
||||
shakeCount += (float)Math.PI/2;
|
||||
if (shakeCount >= Math.PI * 2) {
|
||||
shakeCount %= Math.PI*2;
|
||||
shakesLeft--;
|
||||
}
|
||||
x += (int)(Math.sin(shakeCount)*3);
|
||||
y -= (int)(Math.sin(shakeCount)*3);
|
||||
}
|
||||
int x = this.x;
|
||||
int y = this.y;
|
||||
if (shakesLeft > 0) {
|
||||
shakeCount += (float)Math.PI/2;
|
||||
if (shakeCount >= Math.PI * 2) {
|
||||
shakeCount %= Math.PI*2;
|
||||
shakesLeft--;
|
||||
}
|
||||
x += (int)(Math.sin(shakeCount)*3);
|
||||
y -= (int)(Math.sin(shakeCount)*3);
|
||||
}
|
||||
|
||||
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + width && mouseY < this.y + height;
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -208,9 +208,9 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
}
|
||||
|
||||
public void triggerShake() {
|
||||
if (shakesLeft <= 0) {
|
||||
shakesLeft = 5;
|
||||
}
|
||||
if (shakesLeft <= 0) {
|
||||
shakesLeft = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class SlotEnchanting extends Slot {
|
||||
|
||||
public SlotEnchanting(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
||||
super(inventoryIn, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
public boolean canBeHovered() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public SlotEnchanting(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
||||
super(inventoryIn, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
public boolean canBeHovered() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,24 +15,24 @@ import net.minecraft.util.NonNullList;
|
|||
|
||||
public class SlotEnchantingResult extends SlotEnchanting {
|
||||
|
||||
private final IPageOwner owner;
|
||||
private final InventorySpellBook craftMatrix;
|
||||
private final IPageOwner owner;
|
||||
private final InventorySpellBook craftMatrix;
|
||||
|
||||
private IPageUnlockListener listener;
|
||||
private IPageUnlockListener listener;
|
||||
|
||||
public SlotEnchantingResult(IPageUnlockListener listener, IPageOwner owner, InventorySpellBook craftMatric, IInventory inventory, int index, int xPosition, int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
this.owner = owner;
|
||||
this.listener = listener;
|
||||
craftMatrix = craftMatric;
|
||||
}
|
||||
public SlotEnchantingResult(IPageUnlockListener listener, IPageOwner owner, InventorySpellBook craftMatric, IInventory inventory, int index, int xPosition, int yPosition) {
|
||||
super(inventory, index, xPosition, yPosition);
|
||||
this.owner = owner;
|
||||
this.listener = listener;
|
||||
craftMatrix = craftMatric;
|
||||
}
|
||||
|
||||
public void setListener(IPageUnlockListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
public void setListener(IPageUnlockListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake(EntityPlayer player, ItemStack stack) {
|
||||
@Override
|
||||
public ItemStack onTake(EntityPlayer player, ItemStack stack) {
|
||||
onCrafting(stack);
|
||||
|
||||
ItemStack current = craftMatrix.getCraftResultMatrix().getStackInSlot(0);
|
||||
|
@ -53,8 +53,8 @@ public class SlotEnchantingResult extends SlotEnchanting {
|
|||
craftMatrix.decrStackSize(i, stack.getCount());
|
||||
}
|
||||
|
||||
if (!remainder.isEmpty()) {
|
||||
if (craftMatrix.getStackInSlot(i).isEmpty()) {
|
||||
if (!remainder.isEmpty()) {
|
||||
if (craftMatrix.getStackInSlot(i).isEmpty()) {
|
||||
craftMatrix.setInventorySlotContents(i, remainder);
|
||||
} else {
|
||||
remainder.setCount(stack.getCount());
|
||||
|
@ -62,30 +62,30 @@ public class SlotEnchantingResult extends SlotEnchanting {
|
|||
player.dropItem(remainder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onTake(player, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack, int amount) {
|
||||
onCrafting(stack);
|
||||
}
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack, int amount) {
|
||||
onCrafting(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack) {
|
||||
SpellCraftingEvent.trigger(owner, stack, listener);
|
||||
}
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack) {
|
||||
SpellCraftingEvent.trigger(owner, stack, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemSpell && !SpellRegistry.stackHasEnchantment(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSlotTexture() {
|
||||
@Override
|
||||
public String getSlotTexture() {
|
||||
return "unicopia:items/empty_slot_gem";
|
||||
}
|
||||
}
|
|
@ -20,59 +20,59 @@ public class ItemCloud extends Item implements IMultiItem {
|
|||
|
||||
private static final String[] variants = new String[] {"cloud_small", "cloud_medium", "cloud_large"};
|
||||
|
||||
public ItemCloud(String domain, String name) {
|
||||
super();
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
public ItemCloud(String domain, String name) {
|
||||
super();
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
setCreativeTab(CreativeTabs.MATERIALS);
|
||||
|
||||
maxStackSize = 16;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVariants() {
|
||||
return variants;
|
||||
}
|
||||
@Override
|
||||
public String[] getVariants() {
|
||||
return variants;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
if (!world.isRemote) {
|
||||
RayTraceResult mop = rayTrace(world, player, true);
|
||||
if (!world.isRemote) {
|
||||
RayTraceResult mop = rayTrace(world, player, true);
|
||||
|
||||
BlockPos pos;
|
||||
BlockPos pos;
|
||||
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
pos = mop.getBlockPos().offset(mop.sideHit);
|
||||
} else {
|
||||
pos = player.getPosition();
|
||||
}
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
pos = mop.getBlockPos().offset(mop.sideHit);
|
||||
} else {
|
||||
pos = player.getPosition();
|
||||
}
|
||||
|
||||
EntityCloud cloud = CloudSize.byMetadata(stack.getItemDamage()).createEntity(world);
|
||||
cloud.moveToBlockPosAndAngles(pos, 0, 0);
|
||||
world.spawnEntity(cloud);
|
||||
cloud.moveToBlockPosAndAngles(pos, 0, 0);
|
||||
world.spawnEntity(cloud);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(ItemStack stack) {
|
||||
return super.getTranslationKey(stack) + "." + CloudSize.byMetadata(stack.getItemDamage()).getName();
|
||||
return super.getTranslationKey(stack) + "." + CloudSize.byMetadata(stack.getItemDamage()).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subs) {
|
||||
if (isInCreativeTab(tab)) {
|
||||
for (CloudSize i : CloudSize.values()) {
|
||||
subs.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
subs.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,48 +18,48 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSpellbook extends ItemBook {
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() {
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING);
|
||||
BlockPos pos = source.getBlockPos().offset(facing);
|
||||
int yaw = 0;
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() {
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING);
|
||||
BlockPos pos = source.getBlockPos().offset(facing);
|
||||
int yaw = 0;
|
||||
|
||||
|
||||
//0deg == SOUTH
|
||||
//90deg == WEST
|
||||
//180deg == NORTH
|
||||
//270deg == EAST
|
||||
//0deg == SOUTH
|
||||
//90deg == WEST
|
||||
//180deg == NORTH
|
||||
//270deg == EAST
|
||||
|
||||
/*switch (facing) {
|
||||
case NORTH: yaw -= 90; break;
|
||||
case SOUTH: yaw += 90; break;
|
||||
case EAST: yaw += 180; break;
|
||||
default:
|
||||
}*/
|
||||
/*switch (facing) {
|
||||
case NORTH: yaw -= 90; break;
|
||||
case SOUTH: yaw += 90; break;
|
||||
case EAST: yaw += 180; break;
|
||||
default:
|
||||
}*/
|
||||
|
||||
yaw = facing.getOpposite().getHorizontalIndex() * 90;
|
||||
placeBook(source.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw);
|
||||
stack.shrink(1);
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
yaw = facing.getOpposite().getHorizontalIndex() * 90;
|
||||
placeBook(source.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw);
|
||||
stack.shrink(1);
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
|
||||
public ItemSpellbook(String domain, String name) {
|
||||
super();
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
public ItemSpellbook(String domain, String name) {
|
||||
super();
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
|
||||
setMaxDamage(0);
|
||||
setMaxDamage(0);
|
||||
maxStackSize = 1;
|
||||
setCreativeTab(CreativeTabs.BREWING);
|
||||
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, dispenserBehavior);
|
||||
}
|
||||
}
|
||||
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
if (!world.isRemote && Predicates.MAGI.test(player)) {
|
||||
pos = pos.offset(side);
|
||||
if (!world.isRemote && Predicates.MAGI.test(player)) {
|
||||
pos = pos.offset(side);
|
||||
|
||||
double diffX = player.posX - (pos.getX() + 0.5);
|
||||
double diffZ = player.posZ - (pos.getZ() + 0.5);
|
||||
|
@ -72,19 +72,19 @@ public class ItemSpellbook extends ItemBook {
|
|||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
private static void placeBook(World world, int x, int y, int z, float yaw) {
|
||||
EntitySpellbook book = new EntitySpellbook(world);
|
||||
private static void placeBook(World world, int x, int y, int z, float yaw) {
|
||||
EntitySpellbook book = new EntitySpellbook(world);
|
||||
|
||||
book.setPositionAndRotation(x + 0.5, y, z + 0.5, yaw, 0);
|
||||
book.renderYawOffset = 0;
|
||||
book.prevRotationYaw = yaw;
|
||||
book.setPositionAndRotation(x + 0.5, y, z + 0.5, yaw, 0);
|
||||
book.renderYawOffset = 0;
|
||||
book.prevRotationYaw = yaw;
|
||||
|
||||
world.spawnEntity(book);
|
||||
}
|
||||
world.spawnEntity(book);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import com.minelittlepony.unicopia.forgebullshit.FUF;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
@FUF(reason = "Waiting for mixins?")
|
||||
// pseudo code for things forge can't do.
|
||||
// @Mixin(Entity.class)
|
||||
public interface MixinEntity {
|
||||
|
|
|
@ -14,75 +14,75 @@ import net.minecraft.util.math.MathHelper;
|
|||
|
||||
public class ModelGem extends ModelBase {
|
||||
|
||||
private ModelRenderer body;
|
||||
private ModelRenderer body;
|
||||
|
||||
public ModelGem() {
|
||||
public ModelGem() {
|
||||
textureWidth = 256;
|
||||
textureHeight = 256;
|
||||
|
||||
body = new ModelRenderer(this);
|
||||
body.offsetY = 1.2f;
|
||||
body = new ModelRenderer(this);
|
||||
body.offsetY = 1.2f;
|
||||
|
||||
int size = 1;
|
||||
int size = 1;
|
||||
|
||||
body.cubeList.add(new ModelQuads(body).addFace(
|
||||
new Vertex( size, 0, size, 0, 0.5f),
|
||||
new Vertex(-size, 0, size, 0.25f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0, 0.25f)
|
||||
).addFace(
|
||||
new Vertex( size, 0, size, 0, 0.25f),
|
||||
new Vertex(-size, 0, size, 0.25f, 0),
|
||||
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(size, 0, -size, 0.25f, 0.5f),
|
||||
new Vertex(size, 0, size, 0.5f, 0.25f),
|
||||
new Vertex(0, size * 2, 0, 0.25f, 0.25f),
|
||||
new Vertex(0, size * 2, 0, 0.25f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(size, 0, -size, 0.25f, 0.25f),
|
||||
new Vertex(size, 0, size, 0.5f, 0),
|
||||
new Vertex(0, -size * 2, 0, 0.5f, 0.25f),
|
||||
new Vertex(0, -size * 2, 0, 0.5f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, -size, 0.5f, 0.5f),
|
||||
new Vertex( size, 0, -size, 0.75f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.5f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.5f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, -size, 0.5f, 0.25f),
|
||||
new Vertex( size, 0, -size, 0.75f, 0),
|
||||
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, size, 0.75f, 0.5f),
|
||||
new Vertex(-size, 0, -size, 1, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.75f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.75f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, size, 0.75f, 0.25f),
|
||||
new Vertex(-size, 0, -size, 1, 0),
|
||||
new Vertex( 0, -size * 2, 0, 1, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 1, 0.25f)
|
||||
));
|
||||
}
|
||||
body.cubeList.add(new ModelQuads(body).addFace(
|
||||
new Vertex( size, 0, size, 0, 0.5f),
|
||||
new Vertex(-size, 0, size, 0.25f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0, 0.25f)
|
||||
).addFace(
|
||||
new Vertex( size, 0, size, 0, 0.25f),
|
||||
new Vertex(-size, 0, size, 0.25f, 0),
|
||||
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(size, 0, -size, 0.25f, 0.5f),
|
||||
new Vertex(size, 0, size, 0.5f, 0.25f),
|
||||
new Vertex(0, size * 2, 0, 0.25f, 0.25f),
|
||||
new Vertex(0, size * 2, 0, 0.25f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(size, 0, -size, 0.25f, 0.25f),
|
||||
new Vertex(size, 0, size, 0.5f, 0),
|
||||
new Vertex(0, -size * 2, 0, 0.5f, 0.25f),
|
||||
new Vertex(0, -size * 2, 0, 0.5f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, -size, 0.5f, 0.5f),
|
||||
new Vertex( size, 0, -size, 0.75f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.5f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.5f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, -size, 0.5f, 0.25f),
|
||||
new Vertex( size, 0, -size, 0.75f, 0),
|
||||
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, size, 0.75f, 0.5f),
|
||||
new Vertex(-size, 0, -size, 1, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.75f, 0.25f),
|
||||
new Vertex( 0, size * 2, 0, 0.75f, 0.25f)
|
||||
).addFace(
|
||||
new Vertex(-size, 0, size, 0.75f, 0.25f),
|
||||
new Vertex(-size, 0, -size, 1, 0),
|
||||
new Vertex( 0, -size * 2, 0, 1, 0.25f),
|
||||
new Vertex( 0, -size * 2, 0, 1, 0.25f)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float scale) {
|
||||
@Override
|
||||
public void render(Entity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float scale) {
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
EntitySpell spell = (EntitySpell)entity;
|
||||
EntitySpell spell = (EntitySpell)entity;
|
||||
|
||||
float eyes = entity.getEyeHeight();
|
||||
float eyes = entity.getEyeHeight();
|
||||
|
||||
float floatOffset = MathHelper.sin((spell.ticksExisted + stutter) / 10 + spell.hoverStart) / 10 + 0.1F;
|
||||
float floatOffset = MathHelper.sin((spell.ticksExisted + stutter) / 10 + spell.hoverStart) / 10 + 0.1F;
|
||||
GlStateManager.translate(0, floatOffset - (eyes > 0.25F ? eyes : 0), 0);
|
||||
|
||||
floatOffset = (spell.ticksExisted + stutter) / 20;
|
||||
if (spell.getCurrentLevel() > 0) {
|
||||
floatOffset *= spell.getCurrentLevel() + 1;
|
||||
floatOffset *= spell.getCurrentLevel() + 1;
|
||||
}
|
||||
|
||||
floatOffset += spell.hoverStart;
|
||||
|
@ -139,27 +139,27 @@ public class ModelGem extends ModelBase {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
setLightingConditionsBrightness(entity.getBrightnessForRender());
|
||||
setLightingConditionsBrightness(entity.getBrightnessForRender());
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
protected void renderOverlay(float grow, float scale) {
|
||||
protected void renderOverlay(float grow, float scale) {
|
||||
body.render(scale);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLightingConditionsBrightness(int brightness) {
|
||||
private void setLightingConditionsBrightness(int brightness) {
|
||||
int texX = brightness % 0x10000;
|
||||
int texY = brightness / 0x10000;
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, texX, texY);
|
||||
}
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, texX, texY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotationAngles(float time, float walkSpeed, float stutter, float yaw, float pitch, float increment, Entity entity) {
|
||||
@Override
|
||||
public void setRotationAngles(float time, float walkSpeed, float stutter, float yaw, float pitch, float increment, Entity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ import net.minecraft.client.model.ModelBook;
|
|||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelSpellbook extends ModelBook {
|
||||
public ModelSpellbook() {
|
||||
super();
|
||||
bookSpine = (new ModelRenderer(this)).setTextureOffset(12, 0);
|
||||
bookSpine.addBox(-1, -5, 0, 2, 10, 0, 0.1f);
|
||||
bookSpine.rotateAngleY = ((float)Math.PI / 2F);
|
||||
public ModelSpellbook() {
|
||||
super();
|
||||
bookSpine = (new ModelRenderer(this)).setTextureOffset(12, 0);
|
||||
bookSpine.addBox(-1, -5, 0, 2, 10, 0, 0.1f);
|
||||
bookSpine.rotateAngleY = ((float)Math.PI / 2F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,16 +9,16 @@ public class ParticleRaindrops extends ParticleRain {
|
|||
this(w, x, y, z);
|
||||
}
|
||||
|
||||
public ParticleRaindrops(World w, double x, double y, double z) {
|
||||
super(w, x, y, z);
|
||||
motionY = -0.1;
|
||||
particleMaxAge += 19;
|
||||
public ParticleRaindrops(World w, double x, double y, double z) {
|
||||
super(w, x, y, z);
|
||||
motionY = -0.1;
|
||||
particleMaxAge += 19;
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (onGround) {
|
||||
if (onGround) {
|
||||
motionX *= 0.30000001192092896D;
|
||||
motionY = Math.random() * 0.20000000298023224D + 0.10000000149011612D;
|
||||
motionZ *= 0.30000001192092896D;
|
||||
|
|
|
@ -16,8 +16,8 @@ public class ParticleUnicornMagic extends Particle {
|
|||
this(w, x, y, z, vX, vY, vZ);
|
||||
}
|
||||
|
||||
public ParticleUnicornMagic(World w, double x, double y, double z, double vX, double vY, double vZ) {
|
||||
super(w, x, y, z, vX, vY, vZ);
|
||||
public ParticleUnicornMagic(World w, double x, double y, double z, double vX, double vY, double vZ) {
|
||||
super(w, x, y, z, vX, vY, vZ);
|
||||
motionX = vX;
|
||||
motionY = vY;
|
||||
motionZ = vZ;
|
||||
|
@ -37,13 +37,13 @@ public class ParticleUnicornMagic extends Particle {
|
|||
if (rand.nextBoolean()) particleGreen += 0.5F;
|
||||
|
||||
if (rand.nextBoolean()) {
|
||||
particleGreen *= 2F;
|
||||
particleGreen *= 2F;
|
||||
} else if (rand.nextBoolean()) {
|
||||
particleRed *= 3.9F;
|
||||
particleRed *= 3.9F;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderParticle(BufferBuilder renderer, Entity e, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) {
|
||||
public void renderParticle(BufferBuilder renderer, Entity e, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) {
|
||||
float f6 = 1 - ((particleAge + p_70539_2_) / particleMaxAge);
|
||||
f6 = 1 - f6 * f6;
|
||||
particleScale = portalParticleScale * f6;
|
||||
|
@ -63,7 +63,7 @@ public class ParticleUnicornMagic extends Particle {
|
|||
}
|
||||
|
||||
public void onUpdate() {
|
||||
prevPosX = posX;
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
float var1 = (float)particleAge / (float)particleMaxAge;
|
||||
|
|
|
@ -10,29 +10,29 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
public class RenderGem extends RenderLiving<EntitySpell> {
|
||||
|
||||
private static final ResourceLocation gem = new ResourceLocation("unicopia", "textures/entity/gem.png");
|
||||
private static final ResourceLocation gem = new ResourceLocation("unicopia", "textures/entity/gem.png");
|
||||
|
||||
public RenderGem(RenderManager rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelGem(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntitySpell entity) {
|
||||
return gem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(EntitySpell livingEntity, ICamera camera, double camX, double camY, double camZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntitySpell entity) {
|
||||
return 0;
|
||||
public RenderGem(RenderManager rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelGem(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRenderName(EntitySpell targetEntity) {
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntitySpell entity) {
|
||||
return gem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(EntitySpell livingEntity, ICamera camera, double camX, double camY, double camZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntitySpell entity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRenderName(EntitySpell targetEntity) {
|
||||
return super.canRenderName(targetEntity) && (targetEntity.getAlwaysRenderNameTagForRender()
|
||||
|| targetEntity.hasCustomName() && targetEntity == renderManager.pointedEntity);
|
||||
}
|
||||
|
|
|
@ -11,63 +11,63 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
public class RenderSpellbook extends RenderLiving<EntitySpellbook> {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("textures/entity/enchanting_table_book.png");
|
||||
private static final ResourceLocation texture = new ResourceLocation("textures/entity/enchanting_table_book.png");
|
||||
|
||||
public RenderSpellbook(RenderManager rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelSpellbook(), 0);
|
||||
}
|
||||
public RenderSpellbook(RenderManager rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelSpellbook(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntitySpellbook entity) {
|
||||
return texture;
|
||||
}
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntitySpellbook entity) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntitySpellbook entity) {
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntitySpellbook entity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(EntitySpellbook entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) {
|
||||
@Override
|
||||
protected void renderModel(EntitySpellbook entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) {
|
||||
|
||||
float breath = MathHelper.sin(((float)entity.ticksExisted + stutter) / 20) * 0.01F + 0.1F;
|
||||
float breath = MathHelper.sin(((float)entity.ticksExisted + stutter) / 20) * 0.01F + 0.1F;
|
||||
|
||||
float first_page_rot = walkSpeed + (breath * 10);
|
||||
float second_page_rot = 1 - first_page_rot;
|
||||
float open_angle = 0.9f - walkSpeed;
|
||||
float first_page_rot = walkSpeed + (breath * 10);
|
||||
float second_page_rot = 1 - first_page_rot;
|
||||
float open_angle = 0.9f - walkSpeed;
|
||||
|
||||
if (first_page_rot > 1) first_page_rot = 1;
|
||||
if (second_page_rot > 1) second_page_rot = 1;
|
||||
if (first_page_rot > 1) first_page_rot = 1;
|
||||
if (second_page_rot > 1) second_page_rot = 1;
|
||||
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
GlStateManager.translate(0, 1.44f, 0);
|
||||
} else {
|
||||
GlStateManager.translate(0, 1.2f + breath, 0);
|
||||
}
|
||||
GlStateManager.pushMatrix();
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
GlStateManager.translate(0, 1.44f, 0);
|
||||
} else {
|
||||
GlStateManager.translate(0, 1.2f + breath, 0);
|
||||
}
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
first_page_rot = second_page_rot = open_angle = 0;
|
||||
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.translate(-0.25f, 0, 0);
|
||||
} else {
|
||||
GlStateManager.rotate(-60.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
first_page_rot = second_page_rot = open_angle = 0;
|
||||
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.translate(-0.25f, 0, 0);
|
||||
} else {
|
||||
GlStateManager.rotate(-60.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
GlStateManager.enableCull();
|
||||
super.renderModel(entity, 0, first_page_rot, second_page_rot, open_angle, 0.0F, 0.0625F);
|
||||
GlStateManager.enableCull();
|
||||
super.renderModel(entity, 0, first_page_rot, second_page_rot, open_angle, 0.0F, 0.0625F);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyRotations(EntitySpellbook entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
|
||||
GlStateManager.rotate(-interpolateRotation(entity.prevRotationYaw, entity.rotationYaw, partialTicks), 0, 1, 0);
|
||||
}
|
||||
@Override
|
||||
protected void applyRotations(EntitySpellbook entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
|
||||
GlStateManager.rotate(-interpolateRotation(entity.prevRotationYaw, entity.rotationYaw, partialTicks), 0, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRenderName(EntitySpellbook targetEntity) {
|
||||
@Override
|
||||
protected boolean canRenderName(EntitySpellbook targetEntity) {
|
||||
return super.canRenderName(targetEntity) && (targetEntity.getAlwaysRenderNameTagForRender() || targetEntity.hasCustomName() && targetEntity == renderManager.pointedEntity);
|
||||
}
|
||||
}
|
|
@ -4,23 +4,23 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public abstract class AbstractSpell implements IMagicEffect {
|
||||
|
||||
protected boolean isDead;
|
||||
protected boolean isDirty;
|
||||
protected boolean isDead;
|
||||
protected boolean isDirty;
|
||||
|
||||
@Override
|
||||
public boolean isCraftable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead() {
|
||||
isDead = true;
|
||||
}
|
||||
@Override
|
||||
public void setDead() {
|
||||
isDead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDead() {
|
||||
return isDead;
|
||||
}
|
||||
@Override
|
||||
public boolean getDead() {
|
||||
return isDead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
|
|
|
@ -10,14 +10,14 @@ import net.minecraft.util.EnumFacing;
|
|||
*/
|
||||
public interface IDispenceable extends IMagicEffect {
|
||||
|
||||
/**
|
||||
* Called when dispensed.
|
||||
*
|
||||
* @param pos Block position in front of the dispenser
|
||||
* @param facing Direction of the dispenser
|
||||
* @param source The dispenser currently dispensing
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @return an ActionResult for the type of action to perform.
|
||||
*/
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity);
|
||||
/**
|
||||
* Called when dispensed.
|
||||
*
|
||||
* @param pos Block position in front of the dispenser
|
||||
* @param facing Direction of the dispenser
|
||||
* @param source The dispenser currently dispensing
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @return an ActionResult for the type of action to perform.
|
||||
*/
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity);
|
||||
}
|
||||
|
|
|
@ -10,22 +10,22 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
/**
|
||||
* Gets the name used to identify this effect.
|
||||
*/
|
||||
String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the tint for this spell when applied to a gem.
|
||||
*/
|
||||
int getTint();
|
||||
/**
|
||||
* Gets the tint for this spell when applied to a gem.
|
||||
*/
|
||||
int getTint();
|
||||
|
||||
/**
|
||||
* Sets this effect as dead.
|
||||
*/
|
||||
void setDead();
|
||||
/**
|
||||
* Sets this effect as dead.
|
||||
*/
|
||||
void setDead();
|
||||
|
||||
/**
|
||||
* Returns true if this spell is dead, and must be cleaned up.
|
||||
*/
|
||||
boolean getDead();
|
||||
/**
|
||||
* Returns true if this spell is dead, and must be cleaned up.
|
||||
*/
|
||||
boolean getDead();
|
||||
|
||||
/**
|
||||
* Returns true if this effect has changes that need to be sent to the client.
|
||||
|
@ -37,10 +37,10 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
*/
|
||||
void setDirty(boolean dirty);
|
||||
|
||||
/**
|
||||
* Returns true if this effect can be crafted into a gem.
|
||||
*/
|
||||
boolean isCraftable();
|
||||
/**
|
||||
* Returns true if this effect can be crafted into a gem.
|
||||
*/
|
||||
boolean isCraftable();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -56,30 +56,30 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
*/
|
||||
float getExhaustion(ICaster<?> caster);
|
||||
|
||||
/**
|
||||
* Called when first attached to a gem.
|
||||
*/
|
||||
default void onPlaced(ICaster<?> caster) {
|
||||
/**
|
||||
* Called when first attached to a gem.
|
||||
*/
|
||||
default void onPlaced(ICaster<?> caster) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to a player.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
* @return true to keep alive
|
||||
*/
|
||||
/**
|
||||
* Called every tick when attached to a player.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
* @return true to keep alive
|
||||
*/
|
||||
default boolean updateOnPerson(ICaster<?> caster) {
|
||||
return update(caster);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to an entity.
|
||||
* Called on both sides.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
*/
|
||||
boolean update(ICaster<?> source);
|
||||
/**
|
||||
* Called every tick when attached to an entity.
|
||||
* Called on both sides.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
*/
|
||||
boolean update(ICaster<?> source);
|
||||
|
||||
/**
|
||||
* Called every tick when attached to a player. Used to apply particle effects.
|
||||
|
@ -91,22 +91,22 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
render(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to an entity to produce particle effects.
|
||||
* Is only called on the client side.
|
||||
*
|
||||
* @param source The entity we are attached to.
|
||||
*/
|
||||
void render(ICaster<?> source);
|
||||
/**
|
||||
* Called every tick when attached to an entity to produce particle effects.
|
||||
* Is only called on the client side.
|
||||
*
|
||||
* @param source The entity we are attached to.
|
||||
*/
|
||||
void render(ICaster<?> source);
|
||||
|
||||
/**
|
||||
* Return true to allow the gem update and move.
|
||||
*/
|
||||
default boolean allowAI() {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Return true to allow the gem update and move.
|
||||
*/
|
||||
default boolean allowAI() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default IMagicEffect copy() {
|
||||
return SpellRegistry.instance().copyInstance(this);
|
||||
}
|
||||
default IMagicEffect copy() {
|
||||
return SpellRegistry.instance().copyInstance(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,33 +15,33 @@ import net.minecraft.world.World;
|
|||
*/
|
||||
public interface IUseAction {
|
||||
|
||||
/**
|
||||
* Triggered when the player right clicks a block
|
||||
*
|
||||
* @param stack The current itemstack
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @param player The player
|
||||
* @param world The player's world
|
||||
* @param pos The location clicked
|
||||
* @param side The side of the block clicked
|
||||
* @param hitX X offset inside the block
|
||||
* @param hitY Y offset inside the block
|
||||
* @param hitZ Z offset inside the block
|
||||
*
|
||||
* @return ActionResult for the type of action to perform
|
||||
*/
|
||||
SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ);
|
||||
/**
|
||||
* Triggered when the player right clicks a block
|
||||
*
|
||||
* @param stack The current itemstack
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @param player The player
|
||||
* @param world The player's world
|
||||
* @param pos The location clicked
|
||||
* @param side The side of the block clicked
|
||||
* @param hitX X offset inside the block
|
||||
* @param hitY Y offset inside the block
|
||||
* @param hitZ Z offset inside the block
|
||||
*
|
||||
* @return ActionResult for the type of action to perform
|
||||
*/
|
||||
SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ);
|
||||
|
||||
/**
|
||||
* Triggered when the player right clicks
|
||||
*
|
||||
* @param stack The current itemstack
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @param player The player
|
||||
* @param world The player's world
|
||||
* @param hitEntity The entity in focus, if any
|
||||
*
|
||||
* @return ActionResult for the type of action to perform
|
||||
*/
|
||||
SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity);
|
||||
/**
|
||||
* Triggered when the player right clicks
|
||||
*
|
||||
* @param stack The current itemstack
|
||||
* @param affinity The affinity of the casting artifact
|
||||
* @param player The player
|
||||
* @param world The player's world
|
||||
* @param hitEntity The entity in focus, if any
|
||||
*
|
||||
* @return ActionResult for the type of action to perform
|
||||
*/
|
||||
SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity);
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@ package com.minelittlepony.unicopia.spell;
|
|||
* A type of action to perform after a spell has completed its handling.
|
||||
*/
|
||||
public enum SpellCastResult {
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Place block/gem into the world.
|
||||
*/
|
||||
PLACE,
|
||||
/**
|
||||
* Vanilla behaviour.
|
||||
* In the case of dispensers the item will be ejected into the world.
|
||||
* When right clicking a block the itemstack will be decremented.
|
||||
*/
|
||||
DEFAULT;
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Place block/gem into the world.
|
||||
*/
|
||||
PLACE,
|
||||
/**
|
||||
* Vanilla behaviour.
|
||||
* In the case of dispensers the item will be ejected into the world.
|
||||
* When right clicking a block the itemstack will be decremented.
|
||||
*/
|
||||
DEFAULT;
|
||||
}
|
||||
|
|
|
@ -40,33 +40,33 @@ import net.minecraft.world.World;
|
|||
|
||||
public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseAction, IDispenceable {
|
||||
|
||||
public final StateMapList affected = new StateMapList();
|
||||
public final StateMapList affected = new StateMapList();
|
||||
|
||||
private static final IShape visual_effect_region = new Sphere(false, 0.5);
|
||||
private static final IShape effect_range = new Sphere(false, 4);
|
||||
private static final IShape visual_effect_region = new Sphere(false, 0.5);
|
||||
private static final IShape effect_range = new Sphere(false, 4);
|
||||
|
||||
public SpellFire() {
|
||||
affected.removeBlock(s -> s.getBlock() == Blocks.SNOW_LAYER || s.getBlock() == Blocks.SNOW);
|
||||
affected.removeBlock(s -> s.getBlock() instanceof BlockBush);
|
||||
public SpellFire() {
|
||||
affected.removeBlock(s -> s.getBlock() == Blocks.SNOW_LAYER || s.getBlock() == Blocks.SNOW);
|
||||
affected.removeBlock(s -> s.getBlock() instanceof BlockBush);
|
||||
|
||||
affected.replaceBlock(Blocks.CLAY, Blocks.HARDENED_CLAY);
|
||||
affected.replaceBlock(Blocks.OBSIDIAN, Blocks.LAVA);
|
||||
affected.replaceBlock(Blocks.GRASS, Blocks.DIRT);
|
||||
affected.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
|
||||
affected.replaceBlock(Blocks.CLAY, Blocks.HARDENED_CLAY);
|
||||
affected.replaceBlock(Blocks.OBSIDIAN, Blocks.LAVA);
|
||||
affected.replaceBlock(Blocks.GRASS, Blocks.DIRT);
|
||||
affected.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
|
||||
|
||||
affected.replaceProperty(Blocks.COBBLESTONE_WALL, BlockWall.VARIANT, BlockWall.EnumType.MOSSY, BlockWall.EnumType.NORMAL);
|
||||
affected.replaceProperty(Blocks.STONEBRICK, BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY, BlockStoneBrick.EnumType.DEFAULT);
|
||||
affected.replaceProperty(Blocks.MONSTER_EGG, BlockSilverfish.VARIANT, BlockSilverfish.EnumType.MOSSY_STONEBRICK, BlockSilverfish.EnumType.STONEBRICK);
|
||||
affected.replaceProperty(Blocks.DIRT, BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL, BlockDirt.DirtType.COARSE_DIRT);
|
||||
affected.replaceProperty(Blocks.COBBLESTONE_WALL, BlockWall.VARIANT, BlockWall.EnumType.MOSSY, BlockWall.EnumType.NORMAL);
|
||||
affected.replaceProperty(Blocks.STONEBRICK, BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY, BlockStoneBrick.EnumType.DEFAULT);
|
||||
affected.replaceProperty(Blocks.MONSTER_EGG, BlockSilverfish.VARIANT, BlockSilverfish.EnumType.MOSSY_STONEBRICK, BlockSilverfish.EnumType.STONEBRICK);
|
||||
affected.replaceProperty(Blocks.DIRT, BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL, BlockDirt.DirtType.COARSE_DIRT);
|
||||
|
||||
affected.setProperty(Blocks.FARMLAND, BlockFarmland.MOISTURE, 0);
|
||||
affected.setProperty(Blocks.FARMLAND, BlockFarmland.MOISTURE, 0);
|
||||
|
||||
affected.add(IStateMapping.build(
|
||||
affected.add(IStateMapping.build(
|
||||
s -> s.getBlock() == Blocks.DIRT && s.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT,
|
||||
s -> Math.random() <= 0.15 ?
|
||||
s.withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT)
|
||||
: s));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -88,174 +88,174 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseActi
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
source.spawnParticles(visual_effect_region, source.getCurrentLevel() * 6, pos -> {
|
||||
source.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.x, pos.y, pos.z, 0, 0, 0);
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
source.spawnParticles(visual_effect_region, source.getCurrentLevel() * 6, pos -> {
|
||||
source.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.x, pos.y, pos.z, 0, 0, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
boolean result = false;
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
boolean result = false;
|
||||
|
||||
if (player == null || player.isSneaking()) {
|
||||
result = applyBlocks(world, pos);
|
||||
} else {
|
||||
if (player == null || player.isSneaking()) {
|
||||
result = applyBlocks(world, pos);
|
||||
} else {
|
||||
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
result |= applyBlocks(world, i);
|
||||
}
|
||||
}
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
result |= applyBlocks(world, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = applyEntities(player, world, pos);
|
||||
}
|
||||
if (!result) {
|
||||
result = applyEntities(player, world, pos);
|
||||
}
|
||||
|
||||
return result ? SpellCastResult.DEFAULT : SpellCastResult.NONE;
|
||||
}
|
||||
return result ? SpellCastResult.DEFAULT : SpellCastResult.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
||||
return applyEntitySingle(player, world, hitEntity) ? SpellCastResult.DEFAULT : SpellCastResult.NONE;
|
||||
}
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, @Nonnull Entity hitEntity) {
|
||||
return applyEntitySingle(player, world, hitEntity) ? SpellCastResult.DEFAULT : SpellCastResult.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity) {
|
||||
pos = pos.offset(facing, 4);
|
||||
@Override
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity) {
|
||||
pos = pos.offset(facing, 4);
|
||||
|
||||
boolean result = false;
|
||||
boolean result = false;
|
||||
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
result |= applyBlocks(source.getWorld(), i);
|
||||
}
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
result |= applyBlocks(source.getWorld(), i);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = applyEntities(null, source.getWorld(), pos);
|
||||
}
|
||||
if (!result) {
|
||||
result = applyEntities(null, source.getWorld(), pos);
|
||||
}
|
||||
|
||||
return result ? SpellCastResult.NONE : SpellCastResult.DEFAULT;
|
||||
}
|
||||
return result ? SpellCastResult.NONE : SpellCastResult.DEFAULT;
|
||||
}
|
||||
|
||||
protected boolean applyBlocks(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
protected boolean applyBlocks(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
|
||||
if (id != Blocks.AIR) {
|
||||
if (id == Blocks.ICE || id == Blocks.PACKED_ICE) {
|
||||
world.setBlockState(pos, (world.provider.doesWaterVaporize() ? Blocks.AIR : Blocks.WATER).getDefaultState());
|
||||
playEffect(world, pos);
|
||||
if (id != Blocks.AIR) {
|
||||
if (id == Blocks.ICE || id == Blocks.PACKED_ICE) {
|
||||
world.setBlockState(pos, (world.provider.doesWaterVaporize() ? Blocks.AIR : Blocks.WATER).getDefaultState());
|
||||
playEffect(world, pos);
|
||||
|
||||
return true;
|
||||
} else if (id == Blocks.NETHERRACK) {
|
||||
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
|
||||
return true;
|
||||
} else if (id == Blocks.NETHERRACK) {
|
||||
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
|
||||
|
||||
if (world.rand.nextInt(300) == 0) {
|
||||
world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState());
|
||||
}
|
||||
if (world.rand.nextInt(300) == 0) {
|
||||
world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else if (id == Blocks.REDSTONE_WIRE) {
|
||||
int power = world.rand.nextInt(5) == 3 ? 15 : 3;
|
||||
return true;
|
||||
}
|
||||
} else if (id == Blocks.REDSTONE_WIRE) {
|
||||
int power = world.rand.nextInt(5) == 3 ? 15 : 3;
|
||||
|
||||
sendPower(world, pos, power, 3, 0);
|
||||
sendPower(world, pos, power, 3, 0);
|
||||
|
||||
return true;
|
||||
} else if (id == Blocks.SAND && world.rand.nextInt(10) == 0) {
|
||||
if (isSurroundedBySand(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.GLASS.getDefaultState());
|
||||
return true;
|
||||
} else if (id == Blocks.SAND && world.rand.nextInt(10) == 0) {
|
||||
if (isSurroundedBySand(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.GLASS.getDefaultState());
|
||||
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
} else if (id instanceof BlockLeaves) {
|
||||
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
|
||||
world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState());
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
} else if (id instanceof BlockLeaves) {
|
||||
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
|
||||
world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState());
|
||||
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
IBlockState newState = affected.getConverted(state);
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
IBlockState newState = affected.getConverted(state);
|
||||
|
||||
if (!state.equals(newState)) {
|
||||
world.setBlockState(pos, newState, 3);
|
||||
if (!state.equals(newState)) {
|
||||
world.setBlockState(pos, newState, 3);
|
||||
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
playEffect(world, pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean applyEntities(Entity owner, World world, BlockPos pos) {
|
||||
return VecHelper
|
||||
.findAllEntitiesInRange(owner, world, pos, 3)
|
||||
.filter(i -> applyEntitySingle(owner, world, i))
|
||||
.count() > 0;
|
||||
}
|
||||
protected boolean applyEntities(Entity owner, World world, BlockPos pos) {
|
||||
return VecHelper
|
||||
.findAllEntitiesInRange(owner, world, pos, 3)
|
||||
.filter(i -> applyEntitySingle(owner, world, i))
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
protected boolean applyEntitySingle(Entity owner, World world, Entity e) {
|
||||
if ((!e.equals(owner) ||
|
||||
(owner instanceof EntityPlayer && !Predicates.MAGI.test(owner))) && !(e instanceof EntityItem)
|
||||
&& !(e instanceof IMagicals)) {
|
||||
e.setFire(60);
|
||||
e.attackEntityFrom(getDamageCause(e, (EntityLivingBase)owner), 0.1f);
|
||||
playEffect(world, e.getPosition());
|
||||
return true;
|
||||
}
|
||||
protected boolean applyEntitySingle(Entity owner, World world, Entity e) {
|
||||
if ((!e.equals(owner) ||
|
||||
(owner instanceof EntityPlayer && !Predicates.MAGI.test(owner))) && !(e instanceof EntityItem)
|
||||
&& !(e instanceof IMagicals)) {
|
||||
e.setFire(60);
|
||||
e.attackEntityFrom(getDamageCause(e, (EntityLivingBase)owner), 0.1f);
|
||||
playEffect(world, e.getPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected DamageSource getDamageCause(Entity target, EntityLivingBase attacker) {
|
||||
return MagicalDamageSource.causeMobDamage("fire", attacker);
|
||||
}
|
||||
protected DamageSource getDamageCause(Entity target, EntityLivingBase attacker) {
|
||||
return MagicalDamageSource.causeMobDamage("fire", attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmists power to a piece of redstone
|
||||
*/
|
||||
private void sendPower(World w, BlockPos pos, int power, int max, int i) {
|
||||
IBlockState state = w.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
/**
|
||||
* Transmists power to a piece of redstone
|
||||
*/
|
||||
private void sendPower(World w, BlockPos pos, int power, int max, int i) {
|
||||
IBlockState state = w.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
|
||||
if (i < max && id == Blocks.REDSTONE_WIRE) {
|
||||
i++;
|
||||
if (i < max && id == Blocks.REDSTONE_WIRE) {
|
||||
i++;
|
||||
|
||||
w.setBlockState(pos, state.withProperty(BlockRedstoneWire.POWER, power));
|
||||
w.setBlockState(pos, state.withProperty(BlockRedstoneWire.POWER, power));
|
||||
|
||||
sendPower(w, pos.up(), power, max, i);
|
||||
sendPower(w, pos.down(), power, max, i);
|
||||
sendPower(w, pos.north(), power, max, i);
|
||||
sendPower(w, pos.south(), power, max, i);
|
||||
sendPower(w, pos.east(), power, max, i);
|
||||
sendPower(w, pos.west(), power, max, i);
|
||||
}
|
||||
}
|
||||
sendPower(w, pos.up(), power, max, i);
|
||||
sendPower(w, pos.down(), power, max, i);
|
||||
sendPower(w, pos.north(), power, max, i);
|
||||
sendPower(w, pos.south(), power, max, i);
|
||||
sendPower(w, pos.east(), power, max, i);
|
||||
sendPower(w, pos.west(), power, max, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected void playEffect(World world, BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.AMBIENT, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F, true);
|
||||
protected void playEffect(World world, BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.AMBIENT, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F, true);
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)x + Math.random(), (double)y + Math.random(), (double)z + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSurroundedBySand(World w, BlockPos pos) {
|
||||
return isSand(w, pos.up()) && isSand(w, pos.down()) &&
|
||||
isSand(w, pos.north()) && isSand(w, pos.south()) &&
|
||||
isSand(w, pos.east()) && isSand(w, pos.west());
|
||||
}
|
||||
public static boolean isSurroundedBySand(World w, BlockPos pos) {
|
||||
return isSand(w, pos.up()) && isSand(w, pos.down()) &&
|
||||
isSand(w, pos.north()) && isSand(w, pos.south()) &&
|
||||
isSand(w, pos.east()) && isSand(w, pos.west());
|
||||
}
|
||||
|
||||
public static boolean isSand(World world, BlockPos pos) {
|
||||
Block id = world.getBlockState(pos).getBlock();
|
||||
return id == Blocks.SAND || id == Blocks.GLASS;
|
||||
}
|
||||
public static boolean isSand(World world, BlockPos pos) {
|
||||
Block id = world.getBlockState(pos).getBlock();
|
||||
return id == Blocks.SAND || id == Blocks.GLASS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ import net.minecraft.world.World;
|
|||
|
||||
public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseAction, IDispenceable {
|
||||
|
||||
public final StateMapList affected = new StateMapList();
|
||||
public final StateMapList affected = new StateMapList();
|
||||
|
||||
public SpellIce() {
|
||||
affected.add(IStateMapping.build(
|
||||
s -> s.getMaterial() == Material.WATER,
|
||||
s -> Blocks.ICE.getDefaultState()));
|
||||
public SpellIce() {
|
||||
affected.add(IStateMapping.build(
|
||||
s -> s.getMaterial() == Material.WATER,
|
||||
s -> Blocks.ICE.getDefaultState()));
|
||||
affected.add(IStateMapping.build(
|
||||
s -> s.getMaterial() == Material.LAVA,
|
||||
s -> Blocks.OBSIDIAN.getDefaultState()));
|
||||
|
@ -49,12 +49,12 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseActio
|
|||
|
||||
return s;
|
||||
}));
|
||||
affected.replaceBlock(Blocks.FIRE, Blocks.AIR);
|
||||
affected.setProperty(Blocks.REDSTONE_WIRE, BlockRedstoneWire.POWER, 0);
|
||||
}
|
||||
affected.replaceBlock(Blocks.FIRE, Blocks.AIR);
|
||||
affected.setProperty(Blocks.REDSTONE_WIRE, BlockRedstoneWire.POWER, 0);
|
||||
}
|
||||
|
||||
private final int rad = 3;
|
||||
private final IShape effect_range = new Sphere(false, rad);
|
||||
private final int rad = 3;
|
||||
private final IShape effect_range = new Sphere(false, rad);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -80,93 +80,93 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseActio
|
|||
public void render(ICaster<?> source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity) {
|
||||
return applyBlocks(null, source.getWorld(), pos.offset(facing, rad)) ? SpellCastResult.NONE : SpellCastResult.DEFAULT;
|
||||
}
|
||||
@Override
|
||||
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, SpellAffinity affinity) {
|
||||
return applyBlocks(null, source.getWorld(), pos.offset(facing, rad)) ? SpellCastResult.NONE : SpellCastResult.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (player != null && player.isSneaking()) {
|
||||
applyBlockSingle(world, pos);
|
||||
} else {
|
||||
applyBlocks(player, world, pos);
|
||||
}
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (player != null && player.isSneaking()) {
|
||||
applyBlockSingle(world, pos);
|
||||
} else {
|
||||
applyBlocks(player, world, pos);
|
||||
}
|
||||
|
||||
return SpellCastResult.DEFAULT;
|
||||
}
|
||||
return SpellCastResult.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, Entity hitEntity) {
|
||||
if (hitEntity != null && applyEntitySingle(player, hitEntity)) {
|
||||
return SpellCastResult.DEFAULT;
|
||||
}
|
||||
@Override
|
||||
public SpellCastResult onUse(ItemStack stack, SpellAffinity affinity, EntityPlayer player, World world, Entity hitEntity) {
|
||||
if (hitEntity != null && applyEntitySingle(player, hitEntity)) {
|
||||
return SpellCastResult.DEFAULT;
|
||||
}
|
||||
|
||||
return SpellCastResult.NONE;
|
||||
}
|
||||
return SpellCastResult.NONE;
|
||||
}
|
||||
|
||||
private boolean applyBlocks(EntityPlayer owner, World world, BlockPos pos) {
|
||||
private boolean applyBlocks(EntityPlayer owner, World world, BlockPos pos) {
|
||||
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
applyBlockSingle(world, i);
|
||||
}
|
||||
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
|
||||
applyBlockSingle(world, i);
|
||||
}
|
||||
|
||||
return applyEntities(owner, world, pos);
|
||||
}
|
||||
return applyEntities(owner, world, pos);
|
||||
}
|
||||
|
||||
protected boolean applyEntities(EntityPlayer owner, World world, BlockPos pos) {
|
||||
return VecHelper.findAllEntitiesInRange(owner, world, pos, 3).filter(i ->
|
||||
applyEntitySingle(owner, i)
|
||||
).count() > 0;
|
||||
}
|
||||
protected boolean applyEntities(EntityPlayer owner, World world, BlockPos pos) {
|
||||
return VecHelper.findAllEntitiesInRange(owner, world, pos, 3).filter(i ->
|
||||
applyEntitySingle(owner, i)
|
||||
).count() > 0;
|
||||
}
|
||||
|
||||
protected boolean applyEntitySingle(EntityPlayer owner, Entity e) {
|
||||
if (e instanceof EntityTNTPrimed) {
|
||||
e.setDead();
|
||||
e.getEntityWorld().setBlockState(e.getPosition(), Blocks.TNT.getDefaultState());
|
||||
} else if (e.isBurning()) {
|
||||
e.extinguish();
|
||||
} else {
|
||||
DamageSource d = MagicalDamageSource.causePlayerDamage("cold", owner);
|
||||
e.attackEntityFrom(d, 2);
|
||||
}
|
||||
protected boolean applyEntitySingle(EntityPlayer owner, Entity e) {
|
||||
if (e instanceof EntityTNTPrimed) {
|
||||
e.setDead();
|
||||
e.getEntityWorld().setBlockState(e.getPosition(), Blocks.TNT.getDefaultState());
|
||||
} else if (e.isBurning()) {
|
||||
e.extinguish();
|
||||
} else {
|
||||
DamageSource d = MagicalDamageSource.causePlayerDamage("cold", owner);
|
||||
e.attackEntityFrom(d, 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void applyBlockSingle(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
private void applyBlockSingle(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
|
||||
IBlockState converted = affected.getConverted(state);
|
||||
IBlockState converted = affected.getConverted(state);
|
||||
|
||||
if (!state.equals(converted)) {
|
||||
world.setBlockState(pos, converted, 3);
|
||||
} else if (state.getMaterial() != UMaterials.cloud && state.isSideSolid(world, pos, EnumFacing.UP)
|
||||
|| (id == Blocks.SNOW)
|
||||
|| (id instanceof BlockLeaves)) {
|
||||
incrementIce(world, pos.up());
|
||||
} else if (state.getMaterial() == Material.ICE && world.rand.nextInt(10) == 0) {
|
||||
if (isSurroundedByIce(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.PACKED_ICE.getDefaultState());
|
||||
}
|
||||
}
|
||||
if (!state.equals(converted)) {
|
||||
world.setBlockState(pos, converted, 3);
|
||||
} else if (state.getMaterial() != UMaterials.cloud && state.isSideSolid(world, pos, EnumFacing.UP)
|
||||
|| (id == Blocks.SNOW)
|
||||
|| (id instanceof BlockLeaves)) {
|
||||
incrementIce(world, pos.up());
|
||||
} else if (state.getMaterial() == Material.ICE && world.rand.nextInt(10) == 0) {
|
||||
if (isSurroundedByIce(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.PACKED_ICE.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
world.spawnParticle(EnumParticleTypes.WATER_SPLASH, pos.getX() + world.rand.nextFloat(), pos.getY() + 1, pos.getZ() + world.rand.nextFloat(), 0, 0, 0);
|
||||
}
|
||||
world.spawnParticle(EnumParticleTypes.WATER_SPLASH, pos.getX() + world.rand.nextFloat(), pos.getY() + 1, pos.getZ() + world.rand.nextFloat(), 0, 0, 0);
|
||||
}
|
||||
|
||||
public static boolean isSurroundedByIce(World w, BlockPos pos) {
|
||||
return !PosHelper.adjacentNeighbours(pos).stream().anyMatch(i ->
|
||||
w.getBlockState(i).getMaterial() == Material.ICE
|
||||
);
|
||||
}
|
||||
public static boolean isSurroundedByIce(World w, BlockPos pos) {
|
||||
return !PosHelper.adjacentNeighbours(pos).stream().anyMatch(i ->
|
||||
w.getBlockState(i).getMaterial() == Material.ICE
|
||||
);
|
||||
}
|
||||
|
||||
private void incrementIce(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
private void incrementIce(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block id = state.getBlock();
|
||||
|
||||
if (id == Blocks.AIR || (id instanceof BlockBush)) {
|
||||
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState(), 3);
|
||||
}
|
||||
}
|
||||
if (id == Blocks.AIR || (id instanceof BlockBush)) {
|
||||
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
|||
|
||||
private final ParticleConnection particlEffect = new ParticleConnection();
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return "shield";
|
||||
}
|
||||
|
@ -30,69 +30,69 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
|||
return SpellAffinity.NEUTRAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTint() {
|
||||
return 0x66CDAA;
|
||||
}
|
||||
@Override
|
||||
public int getTint() {
|
||||
return 0x66CDAA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
int radius = 4 + (source.getCurrentLevel() * 2);
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
int radius = 4 + (source.getCurrentLevel() * 2);
|
||||
|
||||
source.spawnParticles(new Sphere(true, radius), radius * 6, pos -> {
|
||||
source.spawnParticles(new Sphere(true, radius), radius * 6, pos -> {
|
||||
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0);
|
||||
});
|
||||
|
||||
particlEffect
|
||||
.ifMissing(source, () -> Particles.instance().spawnParticle(UParticles.SPHERE, true, source.getOriginVector(), 0, 0, 0, radius, getTint(), 30))
|
||||
.ifPresent(p -> p.setAttribute(0, radius));
|
||||
}
|
||||
particlEffect
|
||||
.ifMissing(source, () -> Particles.instance().spawnParticle(UParticles.SPHERE, true, source.getOriginVector(), 0, 0, 0, radius, getTint(), 30))
|
||||
.ifPresent(p -> p.setAttribute(0, radius));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateOnPerson(ICaster<?> source) {
|
||||
if (super.updateOnPerson(source)) {
|
||||
if (source.getEntity().getEntityWorld().getWorldTime() % 50 == 0) {
|
||||
double radius = 4 + (source.getCurrentLevel() * 2);
|
||||
if (!IPower.takeFromPlayer((EntityPlayer)source.getOwner(), radius/4)) {
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean updateOnPerson(ICaster<?> source) {
|
||||
if (super.updateOnPerson(source)) {
|
||||
if (source.getEntity().getEntityWorld().getWorldTime() % 50 == 0) {
|
||||
double radius = 4 + (source.getCurrentLevel() * 2);
|
||||
if (!IPower.takeFromPlayer((EntityPlayer)source.getOwner(), radius/4)) {
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !getDead();
|
||||
}
|
||||
return !getDead();
|
||||
}
|
||||
|
||||
protected double getDrawDropOffRange(ICaster<?> source) {
|
||||
return 4 + (source.getCurrentLevel() * 2);
|
||||
}
|
||||
protected double getDrawDropOffRange(ICaster<?> source) {
|
||||
return 4 + (source.getCurrentLevel() * 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ICaster<?> source) {
|
||||
double radius = getDrawDropOffRange(source);
|
||||
@Override
|
||||
public boolean update(ICaster<?> source) {
|
||||
double radius = getDrawDropOffRange(source);
|
||||
|
||||
Entity owner = source.getOwner();
|
||||
Entity owner = source.getOwner();
|
||||
|
||||
boolean ownerIsValid = source.getAffinity() != SpellAffinity.BAD && Predicates.MAGI.test(owner);
|
||||
boolean ownerIsValid = source.getAffinity() != SpellAffinity.BAD && Predicates.MAGI.test(owner);
|
||||
|
||||
Vec3d origin = source.getOriginVector();
|
||||
Vec3d origin = source.getOriginVector();
|
||||
|
||||
source.findAllEntitiesInRange(radius)
|
||||
.filter(entity -> !(ownerIsValid && entity.equals(owner)))
|
||||
.forEach(i -> {
|
||||
try {
|
||||
double dist = i.getPositionVector().distanceTo(origin);
|
||||
source.findAllEntitiesInRange(radius)
|
||||
.filter(entity -> !(ownerIsValid && entity.equals(owner)))
|
||||
.forEach(i -> {
|
||||
try {
|
||||
double dist = i.getPositionVector().distanceTo(origin);
|
||||
|
||||
applyRadialEffect(source, i, dist, radius);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
applyRadialEffect(source, i, dist, radius);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void applyRadialEffect(ICaster<?> source, Entity target, double distance, double radius) {
|
||||
Vec3d pos = source.getOriginVector();
|
||||
protected void applyRadialEffect(ICaster<?> source, Entity target, double distance, double radius) {
|
||||
Vec3d pos = source.getOriginVector();
|
||||
|
||||
if (ProjectileUtil.isProjectile(target)) {
|
||||
if (!ProjectileUtil.isProjectileThrownBy(target, source.getOwner())) {
|
||||
|
@ -114,52 +114,52 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
|||
|
||||
applyForce(pos, target, force, distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a force to the given entity based on distance from the source.
|
||||
*/
|
||||
protected void applyForce(Vec3d pos, Entity target, double force, double distance) {
|
||||
pos = target.getPositionVector().subtract(pos).normalize().scale(force);
|
||||
/**
|
||||
* Applies a force to the given entity based on distance from the source.
|
||||
*/
|
||||
protected void applyForce(Vec3d pos, Entity target, double force, double distance) {
|
||||
pos = target.getPositionVector().subtract(pos).normalize().scale(force);
|
||||
|
||||
target.addVelocity(
|
||||
pos.x,
|
||||
pos.y + (distance < 1 ? distance : 0),
|
||||
pos.z
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a force to apply based on the given player's given race.
|
||||
*/
|
||||
protected double calculateAdjustedForce(IPlayer player) {
|
||||
double force = 0.75;
|
||||
/**
|
||||
* Returns a force to apply based on the given player's given race.
|
||||
*/
|
||||
protected double calculateAdjustedForce(IPlayer player) {
|
||||
double force = 0.75;
|
||||
|
||||
if (player.getPlayerSpecies().canUseEarth()) {
|
||||
force /= 2;
|
||||
if (player.getPlayerSpecies().canUseEarth()) {
|
||||
force /= 2;
|
||||
|
||||
if (player.getOwner().isSneaking()) {
|
||||
force /= 6;
|
||||
}
|
||||
} else if (player.getPlayerSpecies().canFly()) {
|
||||
force *= 2;
|
||||
}
|
||||
if (player.getOwner().isSneaking()) {
|
||||
force /= 6;
|
||||
}
|
||||
} else if (player.getPlayerSpecies().canFly()) {
|
||||
force *= 2;
|
||||
}
|
||||
|
||||
return force;
|
||||
}
|
||||
return force;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses a projectiles direction to deflect it off the shield's surface.
|
||||
*/
|
||||
protected void ricochet(Entity projectile, Vec3d pos) {
|
||||
Vec3d position = projectile.getPositionVector();
|
||||
Vec3d motion = new Vec3d(projectile.motionX, projectile.motionY, projectile.motionZ);
|
||||
/**
|
||||
* Reverses a projectiles direction to deflect it off the shield's surface.
|
||||
*/
|
||||
protected void ricochet(Entity projectile, Vec3d pos) {
|
||||
Vec3d position = projectile.getPositionVector();
|
||||
Vec3d motion = new Vec3d(projectile.motionX, projectile.motionY, projectile.motionZ);
|
||||
|
||||
Vec3d normal = position.subtract(pos).normalize();
|
||||
Vec3d approach = motion.subtract(normal);
|
||||
Vec3d normal = position.subtract(pos).normalize();
|
||||
Vec3d approach = motion.subtract(normal);
|
||||
|
||||
if (approach.length() >= motion.length()) {
|
||||
ProjectileUtil.setThrowableHeading(projectile, normal, (float)motion.length(), 0);
|
||||
}
|
||||
}
|
||||
if (approach.length() >= motion.length()) {
|
||||
ProjectileUtil.setThrowableHeading(projectile, normal, (float)motion.length(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,45 +12,45 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
|
||||
public class MagicalDamageSource extends EntityDamageSource {
|
||||
|
||||
public static DamageSource create(String type) {
|
||||
return new MagicalDamageSource(type);
|
||||
}
|
||||
|
||||
public static DamageSource causePlayerDamage(String type, EntityPlayer player) {
|
||||
return new MagicalDamageSource(type, player);
|
||||
}
|
||||
|
||||
public static DamageSource causeMobDamage(String type, EntityLivingBase source) {
|
||||
return new MagicalDamageSource(type, source);
|
||||
}
|
||||
|
||||
protected MagicalDamageSource(String type) {
|
||||
this(type, null);
|
||||
}
|
||||
|
||||
protected MagicalDamageSource(String type, Entity source) {
|
||||
super(type, source);
|
||||
setMagicDamage();
|
||||
public static DamageSource create(String type) {
|
||||
return new MagicalDamageSource(type);
|
||||
}
|
||||
|
||||
public ITextComponent getDeathMessage(EntityLivingBase target) {
|
||||
public static DamageSource causePlayerDamage(String type, EntityPlayer player) {
|
||||
return new MagicalDamageSource(type, player);
|
||||
}
|
||||
|
||||
public static DamageSource causeMobDamage(String type, EntityLivingBase source) {
|
||||
return new MagicalDamageSource(type, source);
|
||||
}
|
||||
|
||||
protected MagicalDamageSource(String type) {
|
||||
this(type, null);
|
||||
}
|
||||
|
||||
protected MagicalDamageSource(String type, Entity source) {
|
||||
super(type, source);
|
||||
setMagicDamage();
|
||||
}
|
||||
|
||||
public ITextComponent getDeathMessage(EntityLivingBase target) {
|
||||
Entity attacker = damageSourceEntity instanceof EntityLivingBase ? (EntityLivingBase)damageSourceEntity : target.getRidingEntity();
|
||||
String basic = "death.attack." + this.damageType;
|
||||
|
||||
if (attacker != null && attacker instanceof EntityLivingBase) {
|
||||
String withAttecker = basic + ".player";
|
||||
ItemStack held = attacker instanceof EntityLivingBase ? ((EntityLivingBase)attacker).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
String withAttecker = basic + ".player";
|
||||
ItemStack held = attacker instanceof EntityLivingBase ? ((EntityLivingBase)attacker).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
|
||||
String withItem = withAttecker + ".item";
|
||||
if (held != null && held.hasDisplayName() && I18n.hasKey(withItem)) {
|
||||
return new TextComponentTranslation(withItem, target.getDisplayName(), attacker.getDisplayName(), held.getTextComponent());
|
||||
}
|
||||
String withItem = withAttecker + ".item";
|
||||
if (held != null && held.hasDisplayName() && I18n.hasKey(withItem)) {
|
||||
return new TextComponentTranslation(withItem, target.getDisplayName(), attacker.getDisplayName(), held.getTextComponent());
|
||||
}
|
||||
|
||||
if (I18n.hasKey(withAttecker)) {
|
||||
return new TextComponentTranslation(withAttecker, target.getDisplayName(), attacker.getDisplayName());
|
||||
}
|
||||
}
|
||||
if (I18n.hasKey(withAttecker)) {
|
||||
return new TextComponentTranslation(withAttecker, target.getDisplayName(), attacker.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
return new TextComponentTranslation(basic, target.getDisplayName());
|
||||
return new TextComponentTranslation(basic, target.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,62 +12,62 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
public class ProjectileUtil {
|
||||
|
||||
/**
|
||||
* Checks if the given entity is a projectile.
|
||||
*/
|
||||
public static boolean isProjectile(Entity e) {
|
||||
return e instanceof IProjectile
|
||||
|| e instanceof EntityFireball;
|
||||
}
|
||||
/**
|
||||
* Checks if the given entity is a projectile.
|
||||
*/
|
||||
public static boolean isProjectile(Entity e) {
|
||||
return e instanceof IProjectile
|
||||
|| e instanceof EntityFireball;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an entity is a thrown projectile.
|
||||
*/
|
||||
public static boolean isThrowable(Entity e) {
|
||||
return e instanceof EntityThrowable ||
|
||||
/**
|
||||
* Checks if an entity is a thrown projectile.
|
||||
*/
|
||||
public static boolean isThrowable(Entity e) {
|
||||
return e instanceof EntityThrowable ||
|
||||
e instanceof EntityArrow ||
|
||||
e instanceof EntityFireball;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given projectile was thrown by the given entity
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Entity> boolean isProjectileThrownBy(Entity throwable, @Nullable T e) {
|
||||
if (e == null || !isThrowable(throwable)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks if the given projectile was thrown by the given entity
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Entity> boolean isProjectileThrownBy(Entity throwable, @Nullable T e) {
|
||||
if (e == null || !isThrowable(throwable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return e.equals(getThrowingEntity(throwable));
|
||||
}
|
||||
return e.equals(getThrowingEntity(throwable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the thrower for a projectile or null
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Entity> T getThrowingEntity(Entity throwable) {
|
||||
/**
|
||||
* Gets the thrower for a projectile or null
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Entity> T getThrowingEntity(Entity throwable) {
|
||||
|
||||
if (throwable instanceof EntityArrow) {
|
||||
return (T)((EntityArrow) throwable).shootingEntity;
|
||||
}
|
||||
if (throwable instanceof EntityArrow) {
|
||||
return (T)((EntityArrow) throwable).shootingEntity;
|
||||
}
|
||||
|
||||
if (throwable instanceof EntityFireball) {
|
||||
if (throwable instanceof EntityFireball) {
|
||||
return (T)((EntityFireball) throwable).shootingEntity;
|
||||
}
|
||||
|
||||
if (throwable instanceof EntityLlamaSpit) {
|
||||
if (throwable instanceof EntityLlamaSpit) {
|
||||
return (T)((EntityLlamaSpit) throwable).owner;
|
||||
}
|
||||
}
|
||||
|
||||
if (throwable instanceof EntityThrowable) {
|
||||
return (T)((EntityThrowable) throwable).getThrower();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the velocity and heading for a projectile.
|
||||
*
|
||||
* @param throwable The projectile
|
||||
|
@ -76,14 +76,14 @@ public class ProjectileUtil {
|
|||
* @param inaccuracy Inaccuracy
|
||||
* @return True the projectile's heading was set, false otherwise
|
||||
*/
|
||||
public static void setThrowableHeading(Entity throwable, Vec3d heading, float velocity, float inaccuracy) {
|
||||
public static void setThrowableHeading(Entity throwable, Vec3d heading, float velocity, float inaccuracy) {
|
||||
|
||||
if (throwable instanceof IProjectile) {
|
||||
((IProjectile)throwable).shoot(heading.x, heading.y, heading.z, velocity, inaccuracy);
|
||||
} else {
|
||||
heading = heading.normalize().scale(velocity);
|
||||
if (throwable instanceof IProjectile) {
|
||||
((IProjectile)throwable).shoot(heading.x, heading.y, heading.z, velocity, inaccuracy);
|
||||
} else {
|
||||
heading = heading.normalize().scale(velocity);
|
||||
|
||||
throwable.addVelocity(heading.x - throwable.motionX, heading.y - throwable.motionY, heading.z - throwable.motionZ);
|
||||
}
|
||||
}
|
||||
throwable.addVelocity(heading.x - throwable.motionX, heading.y - throwable.motionY, heading.z - throwable.motionZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,28 +50,28 @@ public interface IStateMapping extends Predicate<IBlockState>, Function<IBlockSt
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this state can be converted by this mapping
|
||||
*
|
||||
* @param state State to check
|
||||
*
|
||||
* @return True if the state can be converted
|
||||
*/
|
||||
/**
|
||||
* Checks if this state can be converted by this mapping
|
||||
*
|
||||
* @param state State to check
|
||||
*
|
||||
* @return True if the state can be converted
|
||||
*/
|
||||
@Override
|
||||
default boolean test(@Nonnull IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
default boolean test(@Nonnull IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given state based on this mapping
|
||||
*
|
||||
* @param state State to convert
|
||||
*
|
||||
* @return The converted state
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
default IBlockState apply(@Nonnull IBlockState state) {
|
||||
return state;
|
||||
}
|
||||
/**
|
||||
* Converts the given state based on this mapping
|
||||
*
|
||||
* @param state State to convert
|
||||
*
|
||||
* @return The converted state
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
default IBlockState apply(@Nonnull IBlockState state) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ import net.minecraft.block.state.IBlockState;
|
|||
*
|
||||
*/
|
||||
public class StateMapList extends ArrayList<IStateMapping> {
|
||||
private static final long serialVersionUID = 2602772651960588745L;
|
||||
private static final long serialVersionUID = 2602772651960588745L;
|
||||
|
||||
public void removeBlock(Predicate<IBlockState> mapper) {
|
||||
add(IStateMapping.removeBlock(mapper));
|
||||
}
|
||||
public void removeBlock(Predicate<IBlockState> mapper) {
|
||||
add(IStateMapping.removeBlock(mapper));
|
||||
}
|
||||
|
||||
public void replaceBlock(Block from, Block to) {
|
||||
public void replaceBlock(Block from, Block to) {
|
||||
add(IStateMapping.replaceBlock(from, to));
|
||||
}
|
||||
|
||||
|
@ -33,32 +33,32 @@ public class StateMapList extends ArrayList<IStateMapping> {
|
|||
add(IStateMapping.setProperty(block, property, to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this collection contains a mapping capable of converting the given state.
|
||||
*
|
||||
* @param state State to check
|
||||
*
|
||||
* @return True if the state can be converted
|
||||
*/
|
||||
public boolean canConvert(@Nullable IBlockState state) {
|
||||
return state != null && stream().anyMatch(i -> i.test(state));
|
||||
}
|
||||
/**
|
||||
* Checks if this collection contains a mapping capable of converting the given state.
|
||||
*
|
||||
* @param state State to check
|
||||
*
|
||||
* @return True if the state can be converted
|
||||
*/
|
||||
public boolean canConvert(@Nullable IBlockState state) {
|
||||
return state != null && stream().anyMatch(i -> i.test(state));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the given state based on the known mappings in this collection.
|
||||
*
|
||||
* @param state State to convert
|
||||
*
|
||||
* @return The converted state if there is one, otherwise null
|
||||
*/
|
||||
@Nonnull
|
||||
public IBlockState getConverted(@Nonnull IBlockState state) {
|
||||
for (IStateMapping i : this) {
|
||||
if (i.test(state)) {
|
||||
return i.apply(state);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Attempts to convert the given state based on the known mappings in this collection.
|
||||
*
|
||||
* @param state State to convert
|
||||
*
|
||||
* @return The converted state if there is one, otherwise null
|
||||
*/
|
||||
@Nonnull
|
||||
public IBlockState getConverted(@Nonnull IBlockState state) {
|
||||
for (IStateMapping i : this) {
|
||||
if (i.test(state)) {
|
||||
return i.apply(state);
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,62 +10,62 @@ import net.minecraft.util.math.Vec3d;
|
|||
*/
|
||||
public interface IShape {
|
||||
|
||||
/**
|
||||
* Rotates this shape around it's center.
|
||||
*
|
||||
* @param u Rotate yaw
|
||||
* @param v Rotate pitch
|
||||
*
|
||||
* @return This Shape
|
||||
*/
|
||||
public IShape setRotation(float u, float v);
|
||||
/**
|
||||
* Rotates this shape around it's center.
|
||||
*
|
||||
* @param u Rotate yaw
|
||||
* @param v Rotate pitch
|
||||
*
|
||||
* @return This Shape
|
||||
*/
|
||||
public IShape setRotation(float u, float v);
|
||||
|
||||
/**
|
||||
* Get the volume of space filled by this shape, or the surface area if hollow.
|
||||
*
|
||||
* @return double volume
|
||||
*/
|
||||
public double getVolumeOfSpawnableSpace();
|
||||
/**
|
||||
* Get the volume of space filled by this shape, or the surface area if hollow.
|
||||
*
|
||||
* @return double volume
|
||||
*/
|
||||
public double getVolumeOfSpawnableSpace();
|
||||
|
||||
/**
|
||||
* X offset from the shape's origin.
|
||||
*
|
||||
* @return X
|
||||
*/
|
||||
public double getXOffset();
|
||||
/**
|
||||
* X offset from the shape's origin.
|
||||
*
|
||||
* @return X
|
||||
*/
|
||||
public double getXOffset();
|
||||
|
||||
/**
|
||||
* Y offset from the shape's origin.
|
||||
*
|
||||
* @return Y
|
||||
*/
|
||||
public double getYOffset();
|
||||
/**
|
||||
* Y offset from the shape's origin.
|
||||
*
|
||||
* @return Y
|
||||
*/
|
||||
public double getYOffset();
|
||||
|
||||
/**
|
||||
* Z offset from the shape's origin.
|
||||
*
|
||||
* @return Z
|
||||
*/
|
||||
public double getZOffset();
|
||||
/**
|
||||
* Z offset from the shape's origin.
|
||||
*
|
||||
* @return Z
|
||||
*/
|
||||
public double getZOffset();
|
||||
|
||||
/**
|
||||
* Gets the lower bounds of the region occupied by this shape.
|
||||
*/
|
||||
public Vec3d getLowerBound();
|
||||
/**
|
||||
* Gets the lower bounds of the region occupied by this shape.
|
||||
*/
|
||||
public Vec3d getLowerBound();
|
||||
|
||||
/**
|
||||
* Gets the upper bound of the region occupied by this shape.
|
||||
*/
|
||||
public Vec3d getUpperBound();
|
||||
/**
|
||||
* Gets the upper bound of the region occupied by this shape.
|
||||
*/
|
||||
public Vec3d getUpperBound();
|
||||
|
||||
/**
|
||||
* Computes a random coordinate that falls within this shape's designated area.
|
||||
*/
|
||||
public Vec3d computePoint(Random rand);
|
||||
/**
|
||||
* Computes a random coordinate that falls within this shape's designated area.
|
||||
*/
|
||||
public Vec3d computePoint(Random rand);
|
||||
|
||||
/**
|
||||
* Checks if the given point is on the edge, or if not hollow the inside, of this shape.
|
||||
* @return
|
||||
*/
|
||||
public boolean isPointInside(Vec3d point);
|
||||
/**
|
||||
* Checks if the given point is on the edge, or if not hollow the inside, of this shape.
|
||||
* @return
|
||||
*/
|
||||
public boolean isPointInside(Vec3d point);
|
||||
}
|
||||
|
|
|
@ -11,87 +11,87 @@ import net.minecraft.util.math.Vec3d;
|
|||
*/
|
||||
public class Line implements IShape {
|
||||
|
||||
double len;
|
||||
double len;
|
||||
|
||||
double dX;
|
||||
double dY;
|
||||
double dZ;
|
||||
double dX;
|
||||
double dY;
|
||||
double dZ;
|
||||
|
||||
double sX;
|
||||
double sY;
|
||||
double sZ;
|
||||
double sX;
|
||||
double sY;
|
||||
double sZ;
|
||||
|
||||
private float yaw = 0;
|
||||
private float pitch = 0;
|
||||
private float yaw = 0;
|
||||
private float pitch = 0;
|
||||
|
||||
/**
|
||||
* Creates a line with a given length, starting point, and gradient represented
|
||||
* by another point.
|
||||
*
|
||||
* @param length Length of this line
|
||||
* @param startX Offset X from origin
|
||||
* @param startY Offset Y from origin
|
||||
* @param startZ Offset Z from origin
|
||||
* @param deltaX Change in X
|
||||
* @param deltaY Change in Y
|
||||
* @param deltaZ Change in Z
|
||||
*/
|
||||
public Line(double length, double startX, double startY, double startZ, double deltaX, double deltaY, double deltaZ) {
|
||||
len = length;
|
||||
dX = deltaX;
|
||||
dY = deltaY;
|
||||
dZ = deltaZ;
|
||||
sX = startX;
|
||||
sY = startY;
|
||||
sZ = startZ;
|
||||
}
|
||||
/**
|
||||
* Creates a line with a given length, starting point, and gradient represented
|
||||
* by another point.
|
||||
*
|
||||
* @param length Length of this line
|
||||
* @param startX Offset X from origin
|
||||
* @param startY Offset Y from origin
|
||||
* @param startZ Offset Z from origin
|
||||
* @param deltaX Change in X
|
||||
* @param deltaY Change in Y
|
||||
* @param deltaZ Change in Z
|
||||
*/
|
||||
public Line(double length, double startX, double startY, double startZ, double deltaX, double deltaY, double deltaZ) {
|
||||
len = length;
|
||||
dX = deltaX;
|
||||
dY = deltaY;
|
||||
dZ = deltaZ;
|
||||
sX = startX;
|
||||
sY = startY;
|
||||
sZ = startZ;
|
||||
}
|
||||
|
||||
public Line(Vec3d start, Vec3d end) {
|
||||
Vec3d lenV = end.subtract(start);
|
||||
public Line(Vec3d start, Vec3d end) {
|
||||
Vec3d lenV = end.subtract(start);
|
||||
|
||||
len = lenV.length();
|
||||
len = lenV.length();
|
||||
|
||||
sX = start.x;
|
||||
sY = start.y;
|
||||
sZ = start.z;
|
||||
sX = start.x;
|
||||
sY = start.y;
|
||||
sZ = start.z;
|
||||
|
||||
dX = lenV.x / len;
|
||||
dY = lenV.y / len;
|
||||
dZ = lenV.z / len;
|
||||
}
|
||||
dX = lenV.x / len;
|
||||
dY = lenV.y / len;
|
||||
dZ = lenV.z / len;
|
||||
}
|
||||
|
||||
public double getVolumeOfSpawnableSpace() {
|
||||
return len;
|
||||
}
|
||||
public double getVolumeOfSpawnableSpace() {
|
||||
return len;
|
||||
}
|
||||
|
||||
public double getXOffset() {
|
||||
return sX;
|
||||
}
|
||||
public double getXOffset() {
|
||||
return sX;
|
||||
}
|
||||
|
||||
public double getYOffset() {
|
||||
return sY;
|
||||
}
|
||||
public double getYOffset() {
|
||||
return sY;
|
||||
}
|
||||
|
||||
public double getZOffset() {
|
||||
return sZ;
|
||||
}
|
||||
public double getZOffset() {
|
||||
return sZ;
|
||||
}
|
||||
|
||||
public Vec3d computePoint(Random rand) {
|
||||
double distance = MathHelper.nextDouble(rand, 0, len);
|
||||
return new Vec3d(dX, dY, dZ).scale(distance).add(sX, sY, sZ).rotateYaw(yaw).rotatePitch(pitch);
|
||||
}
|
||||
public Vec3d computePoint(Random rand) {
|
||||
double distance = MathHelper.nextDouble(rand, 0, len);
|
||||
return new Vec3d(dX, dY, dZ).scale(distance).add(sX, sY, sZ).rotateYaw(yaw).rotatePitch(pitch);
|
||||
}
|
||||
|
||||
public Line setRotation(float u, float v) {
|
||||
yaw = u;
|
||||
pitch = v;
|
||||
return this;
|
||||
}
|
||||
public Line setRotation(float u, float v) {
|
||||
yaw = u;
|
||||
pitch = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPointInside(Vec3d point) {
|
||||
point = point.rotateYaw(-yaw).rotatePitch(-pitch);
|
||||
public boolean isPointInside(Vec3d point) {
|
||||
point = point.rotateYaw(-yaw).rotatePitch(-pitch);
|
||||
|
||||
return point.x/dX == point.y/dY && point.x/dX == point.z/dZ;
|
||||
}
|
||||
return point.x/dX == point.y/dY && point.x/dX == point.z/dZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLowerBound() {
|
||||
|
|
|
@ -11,117 +11,117 @@ import java.util.Random;
|
|||
*/
|
||||
public class Sphere implements IShape {
|
||||
|
||||
protected final Vec3d stretch;
|
||||
private final boolean hollow;
|
||||
private final double rad;
|
||||
protected final Vec3d stretch;
|
||||
private final boolean hollow;
|
||||
private final double rad;
|
||||
|
||||
private float yaw = 0;
|
||||
private float pitch = 0;
|
||||
private float yaw = 0;
|
||||
private float pitch = 0;
|
||||
|
||||
private final double volume;
|
||||
private final double volume;
|
||||
|
||||
/**
|
||||
* Creates a uniform sphere.
|
||||
*
|
||||
* @param hollow True if this shape must be hollow.
|
||||
* @param radius Sphere radius
|
||||
*/
|
||||
public Sphere(boolean hollow, double radius) {
|
||||
this(hollow, radius, 1, 1, 1);
|
||||
}
|
||||
/**
|
||||
* Creates a uniform sphere.
|
||||
*
|
||||
* @param hollow True if this shape must be hollow.
|
||||
* @param radius Sphere radius
|
||||
*/
|
||||
public Sphere(boolean hollow, double radius) {
|
||||
this(hollow, radius, 1, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sphere of arbitrary dimensions.
|
||||
* <p>
|
||||
* Can be used to create a flat circle by setting one of the stretch parameters to 0.
|
||||
* If you set two of them to 0 it will probably produce a line.
|
||||
*
|
||||
* @param hollow True if this shape must be hollow.
|
||||
* @param radius Sphere radius
|
||||
* @param stretchX Warp this shape's X-axis
|
||||
* @param stretchY Warp this shape's Y-axis
|
||||
* @param stretchZ Warp this shape's Z-axis
|
||||
*
|
||||
*/
|
||||
public Sphere(boolean hollow, double radius, float stretchX, float stretchY, float stretchZ) {
|
||||
this.hollow = hollow;
|
||||
stretch = new Vec3d(stretchX, stretchY, stretchZ);
|
||||
rad = radius;
|
||||
volume = computeSpawnableSpace();
|
||||
}
|
||||
/**
|
||||
* Creates a sphere of arbitrary dimensions.
|
||||
* <p>
|
||||
* Can be used to create a flat circle by setting one of the stretch parameters to 0.
|
||||
* If you set two of them to 0 it will probably produce a line.
|
||||
*
|
||||
* @param hollow True if this shape must be hollow.
|
||||
* @param radius Sphere radius
|
||||
* @param stretchX Warp this shape's X-axis
|
||||
* @param stretchY Warp this shape's Y-axis
|
||||
* @param stretchZ Warp this shape's Z-axis
|
||||
*
|
||||
*/
|
||||
public Sphere(boolean hollow, double radius, float stretchX, float stretchY, float stretchZ) {
|
||||
this.hollow = hollow;
|
||||
stretch = new Vec3d(stretchX, stretchY, stretchZ);
|
||||
rad = radius;
|
||||
volume = computeSpawnableSpace();
|
||||
}
|
||||
|
||||
public double getVolumeOfSpawnableSpace() {
|
||||
return volume;
|
||||
}
|
||||
public double getVolumeOfSpawnableSpace() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
private double computeSpawnableSpace() {
|
||||
if (hollow) {
|
||||
if (stretch.x == stretch.x && stretch.y == stretch.z) {
|
||||
double radius = rad * stretch.x;
|
||||
return 4 * Math.PI * radius * radius;
|
||||
}
|
||||
return computeEllipsoidArea(rad, stretch);
|
||||
}
|
||||
return computeEllipsoidVolume(rad, stretch);
|
||||
}
|
||||
private double computeSpawnableSpace() {
|
||||
if (hollow) {
|
||||
if (stretch.x == stretch.x && stretch.y == stretch.z) {
|
||||
double radius = rad * stretch.x;
|
||||
return 4 * Math.PI * radius * radius;
|
||||
}
|
||||
return computeEllipsoidArea(rad, stretch);
|
||||
}
|
||||
return computeEllipsoidVolume(rad, stretch);
|
||||
}
|
||||
|
||||
public static double computeEllipsoidArea(double rad, Vec3d stretch) {
|
||||
double p = 1.6075;
|
||||
double result = Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.y, p);
|
||||
result += Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.z, p);
|
||||
result += Math.pow(rad * stretch.y, p) * Math.pow(rad * stretch.y, p);
|
||||
result /= 3;
|
||||
return 2 * Math.PI * Math.pow(result, 1/p);
|
||||
}
|
||||
public static double computeEllipsoidArea(double rad, Vec3d stretch) {
|
||||
double p = 1.6075;
|
||||
double result = Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.y, p);
|
||||
result += Math.pow(rad * stretch.x, p) * Math.pow(rad * stretch.z, p);
|
||||
result += Math.pow(rad * stretch.y, p) * Math.pow(rad * stretch.y, p);
|
||||
result /= 3;
|
||||
return 2 * Math.PI * Math.pow(result, 1/p);
|
||||
}
|
||||
|
||||
public static double computeEllipsoidVolume(double rad, Vec3d stretch) {
|
||||
double result = (4/3) * Math.PI;
|
||||
result *= (rad * stretch.x);
|
||||
result *= (rad * stretch.y);
|
||||
result *= (rad * stretch.z);
|
||||
return result;
|
||||
}
|
||||
public static double computeEllipsoidVolume(double rad, Vec3d stretch) {
|
||||
double result = (4/3) * Math.PI;
|
||||
result *= (rad * stretch.x);
|
||||
result *= (rad * stretch.y);
|
||||
result *= (rad * stretch.z);
|
||||
return result;
|
||||
}
|
||||
|
||||
public double getXOffset() {
|
||||
return 0;
|
||||
}
|
||||
public double getXOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getYOffset() {
|
||||
return 0;
|
||||
}
|
||||
public double getYOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getZOffset() {
|
||||
return 0;
|
||||
}
|
||||
public double getZOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Vec3d computePoint(Random rand) {
|
||||
double rad = this.rad;
|
||||
public Vec3d computePoint(Random rand) {
|
||||
double rad = this.rad;
|
||||
|
||||
if (!hollow) {
|
||||
rad = MathHelper.nextDouble(rand, 0, rad);
|
||||
}
|
||||
if (!hollow) {
|
||||
rad = MathHelper.nextDouble(rand, 0, rad);
|
||||
}
|
||||
|
||||
double z = MathHelper.nextDouble(rand, -rad, rad);
|
||||
double phi = MathHelper.nextDouble(rand, 0, Math.PI * 2);
|
||||
double theta = Math.asin(z / rad);
|
||||
double z = MathHelper.nextDouble(rand, -rad, rad);
|
||||
double phi = MathHelper.nextDouble(rand, 0, Math.PI * 2);
|
||||
double theta = Math.asin(z / rad);
|
||||
|
||||
return new Vec3d(rad * Math.cos(theta) * Math.cos(phi) * stretch.x, rad * Math.cos(theta) * Math.sin(phi) * stretch.y, z * stretch.z).rotateYaw(yaw).rotatePitch(pitch);
|
||||
}
|
||||
return new Vec3d(rad * Math.cos(theta) * Math.cos(phi) * stretch.x, rad * Math.cos(theta) * Math.sin(phi) * stretch.y, z * stretch.z).rotateYaw(yaw).rotatePitch(pitch);
|
||||
}
|
||||
|
||||
public Sphere setRotation(float u, float v) {
|
||||
yaw = u;
|
||||
pitch = v;
|
||||
return this;
|
||||
}
|
||||
public Sphere setRotation(float u, float v) {
|
||||
yaw = u;
|
||||
pitch = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPointInside(Vec3d point) {
|
||||
point = point.rotateYaw(-yaw).rotatePitch(-pitch);
|
||||
point = new Vec3d(point.x / stretch.x, point.y / stretch.y, point.z / stretch.z);
|
||||
public boolean isPointInside(Vec3d point) {
|
||||
point = point.rotateYaw(-yaw).rotatePitch(-pitch);
|
||||
point = new Vec3d(point.x / stretch.x, point.y / stretch.y, point.z / stretch.z);
|
||||
|
||||
double dist = point.length();
|
||||
double dist = point.length();
|
||||
|
||||
return hollow ? dist == rad : dist <= rad;
|
||||
}
|
||||
return hollow ? dist == rad : dist <= rad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getLowerBound() {
|
||||
|
|
|
@ -19,26 +19,26 @@ import net.minecraft.world.World;
|
|||
|
||||
public class VecHelper {
|
||||
|
||||
/**
|
||||
* Performs a ray cast from the given entity and returns a result for the first block that ray intercepts.
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult rayTrace(Entity e, double distance, float partialTicks) {
|
||||
/**
|
||||
* Performs a ray cast from the given entity and returns a result for the first block that ray intercepts.
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult rayTrace(Entity e, double distance, float partialTicks) {
|
||||
Vec3d pos = e.getPositionEyes(partialTicks);
|
||||
Vec3d look = e.getLook(partialTicks).scale(distance);
|
||||
|
||||
return e.world.rayTraceBlocks(pos, pos.add(look), false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets the entity the player is currently looking at, or null.
|
||||
*/
|
||||
@Nullable
|
||||
@Nullable
|
||||
public static Entity getLookedAtEntity(EntityLivingBase e, int reach) {
|
||||
RayTraceResult objectMouseOver = getObjectMouseOver(e, reach, 1);
|
||||
|
||||
|
@ -76,32 +76,32 @@ public class VecHelper {
|
|||
.expand(1, 1, 1), predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a ray trace from the given entity and returns a result for the first Entity or block that the ray intercepts.
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult getObjectMouseOver(Entity e, double distance, float partialTick) {
|
||||
return getObjectMouseOver(e, distance, partialTick, EntitySelectors.NOT_SPECTATING);
|
||||
}
|
||||
/**
|
||||
* Performs a ray trace from the given entity and returns a result for the first Entity or block that the ray intercepts.
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult getObjectMouseOver(Entity e, double distance, float partialTick) {
|
||||
return getObjectMouseOver(e, distance, partialTick, EntitySelectors.NOT_SPECTATING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a ray trace from the given entity and returns a result for the first Entity that passing the given predicate or block that the ray intercepts.
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
* @param predicate Predicate test to filter entities
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult getObjectMouseOver(Entity e, double distance, float partialTick, Predicate<Entity> predicate) {
|
||||
/**
|
||||
* Performs a ray trace from the given entity and returns a result for the first Entity that passing the given predicate or block that the ray intercepts.
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* @param e Entity to start from
|
||||
* @param distance Maximum distance
|
||||
* @param partialTick Client partial ticks
|
||||
* @param predicate Predicate test to filter entities
|
||||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static RayTraceResult getObjectMouseOver(Entity e, double distance, float partialTick, Predicate<Entity> predicate) {
|
||||
RayTraceResult tracedBlock = rayTrace(e, distance, partialTick);
|
||||
|
||||
double totalTraceDistance = distance;
|
||||
|
|
Loading…
Reference in a new issue