Fixed server sided issue with Attractor Array
Added Movement Array, and helped generalize the Arrays a bit more
This commit is contained in:
parent
22c1f0db55
commit
1836fc742d
|
@ -56,6 +56,11 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
|||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive)
|
||||
{
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockPos pos = tile.getPos();
|
||||
counter++;
|
||||
if (counter < 10)
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||
|
||||
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
|
||||
{
|
||||
|
@ -17,6 +23,46 @@ public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
||||
{
|
||||
double motionY = 0.5;
|
||||
double speed = 3;
|
||||
EnumFacing direction = array.getRotation();
|
||||
|
||||
entity.motionY = motionY;
|
||||
entity.fallDistance = 0;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case NORTH:
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = -speed;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = speed;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
entity.motionX = -speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
entity.motionX = speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AlchemyArrayEffect
|
||||
|
@ -23,7 +24,7 @@ public abstract class AlchemyArrayEffect
|
|||
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AlchemyCircleRenderer
|
||||
{
|
||||
|
@ -72,6 +73,13 @@ public class AlchemyCircleRenderer
|
|||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
if (!(tile instanceof TileAlchemyArray))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer wr = tessellator.getBuffer();
|
||||
|
||||
|
@ -94,6 +102,7 @@ public class AlchemyCircleRenderer
|
|||
|
||||
// Specify which face this "circle" is located on
|
||||
EnumFacing sideHit = EnumFacing.UP;
|
||||
EnumFacing rotation = tileArray.getRotation();
|
||||
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
|
@ -125,6 +134,9 @@ public class AlchemyCircleRenderer
|
|||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
|
@ -150,5 +162,6 @@ public class AlchemyCircleRenderer
|
|||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IAlchemyArray
|
||||
{
|
||||
public abstract EnumFacing getRotation();
|
||||
}
|
|
@ -9,6 +9,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer
|
||||
{
|
||||
|
@ -57,6 +58,13 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
@Override
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
if (!(tile instanceof TileAlchemyArray))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer wr = tessellator.getBuffer();
|
||||
|
||||
|
@ -78,6 +86,7 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
|
||||
// Specify which face this "circle" is located on
|
||||
EnumFacing sideHit = EnumFacing.UP;
|
||||
EnumFacing rotation = tileArray.getRotation();
|
||||
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
|
@ -109,6 +118,9 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
double var31 = 0.0D;
|
||||
|
@ -133,5 +145,6 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
||||
{
|
||||
|
@ -31,7 +32,7 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
@Override
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (craftTime - offset) * 5f;
|
||||
|
@ -49,6 +50,13 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
@Override
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
if (!(tile instanceof TileAlchemyArray))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer wr = tessellator.getBuffer();
|
||||
|
||||
|
@ -69,6 +77,7 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
|
||||
// Specify which face this "circle" is located on
|
||||
EnumFacing sideHit = EnumFacing.UP;
|
||||
EnumFacing rotation = tileArray.getRotation();
|
||||
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
|
@ -100,6 +109,9 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 1, 0);
|
||||
// GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
// GlStateManager.rotate(secondaryRot, 0, 1, 0);
|
||||
|
@ -125,5 +137,6 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer
|
|||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
@ -21,6 +22,7 @@ import WayofTime.bloodmagic.BloodMagic;
|
|||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemArcaneAshes extends Item implements IVariantProvider
|
||||
|
@ -49,7 +51,14 @@ public class ItemArcaneAshes extends Item implements IVariantProvider
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
EnumFacing rotation = EnumFacing.fromAngle(player.getRotationYawHead());
|
||||
world.setBlockState(newPos, ModBlocks.alchemyArray.getDefaultState());
|
||||
TileEntity tile = world.getTileEntity(newPos);
|
||||
if (tile instanceof TileAlchemyArray)
|
||||
{
|
||||
((TileAlchemyArray) tile).setRotation(rotation);
|
||||
}
|
||||
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
package WayofTime.bloodmagic.livingArmour.upgrade;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade
|
||||
{
|
||||
|
|
|
@ -229,7 +229,7 @@ public class ModRecipes
|
|||
AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_TRANSPOSITION), new ItemStack(ModItems.slate, 1, 3), new ItemStack(ModItems.sigilTransposition), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/WIPArray.png"));
|
||||
|
||||
AlchemyArrayRecipeRegistry.registerRecipe(new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.ROTTEN_FLESH), new AlchemyArrayEffectAttractor("attractor"), new AttractorAlchemyCircleRenderer());
|
||||
AlchemyArrayRecipeRegistry.registerRecipe(new ItemStack(Items.GHAST_TEAR), new ItemStack(Items.GHAST_TEAR), new AlchemyArrayEffectMovement("attractor"), new StaticAlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/MovementArray.png")));
|
||||
AlchemyArrayRecipeRegistry.registerRecipe(new ItemStack(Items.FEATHER), new ItemStack(Items.REDSTONE), new AlchemyArrayEffectMovement("movement"), new StaticAlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/MovementArray.png")));
|
||||
}
|
||||
|
||||
public static void addCompressionHandlers()
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
|
||||
|
||||
public class TileAlchemyArray extends TileInventory implements ITickable
|
||||
public class TileAlchemyArray extends TileInventory implements ITickable, IAlchemyArray
|
||||
{
|
||||
public boolean isActive = false;
|
||||
public int activeCounter = 0;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public EnumFacing rotation = EnumFacing.HORIZONTALS[0];;
|
||||
|
||||
private String key = "empty";
|
||||
private AlchemyArrayEffect arrayEffect;
|
||||
|
||||
|
@ -26,7 +35,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
{
|
||||
if (arrayEffect != null)
|
||||
{
|
||||
arrayEffect.onEntityCollidedWithBlock(worldObj, pos, state, entity);
|
||||
arrayEffect.onEntityCollidedWithBlock(this, worldObj, pos, state, entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +46,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
this.isActive = tagCompound.getBoolean("isActive");
|
||||
this.activeCounter = tagCompound.getInteger("activeCounter");
|
||||
this.key = tagCompound.getString("key");
|
||||
this.rotation = EnumFacing.HORIZONTALS[tagCompound.getInteger(Constants.NBT.DIRECTION)];
|
||||
|
||||
NBTTagCompound arrayTag = tagCompound.getCompoundTag("arrayTag");
|
||||
arrayEffect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(key);
|
||||
|
@ -53,6 +63,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("activeCounter", activeCounter);
|
||||
tagCompound.setString("key", "".equals(key) ? "empty" : key);
|
||||
tagCompound.setInteger(Constants.NBT.DIRECTION, rotation.getHorizontalIndex());
|
||||
|
||||
NBTTagCompound arrayTag = new NBTTagCompound();
|
||||
if (arrayEffect != null)
|
||||
|
|
Loading…
Reference in a new issue