Giving potion effect Slowness III or more keeps them from moving. You could also have it place an ice block (not packed ice, regular) at the entity's position.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
You could also create a new TileEntity / Block that you are able to walk through. I have done this with a "liquid" that isn't supposed to flow / be an actual liquid. Then when you send the packet to slow the entity, also have it place the block where they are standing and one above that. In the TE of the blocks that are placed, it would count to their melt point and then make them disappear.
You could also get more creative and make the blocks no full 3d cubes. Make them partial block size just enough to surround the player.
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
You could also create a new TileEntity / Block that you are able to walk through. I have done this with a "liquid" that isn't supposed to flow / be an actual liquid. Then when you send the packet to slow the entity, also have it place the block where they are standing and one above that. In the TE of the blocks that are placed, it would count to their melt point and then make them disappear.
You could also get more creative and make the blocks no full 3d cubes. Make them partial block size just enough to surround the player.
Instead of a Tile Entity, you could call Block#setTickRandomly(true) in the constructor and make the block disappear in the Block#updateTick. However, this means the blocks will stay for 3 to 10 seconds before disappearing instead of lasting an exact amount of time.
Making blocks non-full cubes is very easy in 1.7.10, by calling Block#setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ).
Making blocks not do collisions is easy in both 1.7.10 and 1.8.
I didn't think packets were necessary to give potion effects... Just call EntityLiving#addPotionEffect.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Instead of a Tile Entity, you could call Block#setTickRandomly(true) in the constructor and make the block disappear in the Block#updateTick. However, this means the blocks will stay for 3 to 10 seconds before disappearing instead of lasting an exact amount of time.
Making blocks non-full cubes is very easy in 1.7.10, by calling Block#setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ).
Making blocks not do collisions is easy in both 1.7.10 and 1.8.
I didn't think packets were necessary to give potion effects... Just call EntityLiving#addPotionEffect.
Much appreciated on all these great ideas. Planning to work on it and I will post some results.
Giving potion effect Slowness III or more keeps them from moving. You could also have it place an ice block (not packed ice, regular) at the entity's position.
How would you place the block at the entity's position? every thing I have tried allows me to put block's everywhere BUT the entity position ...ie,, I can surround the entity , etc. but even if I make my block material water, lava , or air I cannot put it where the entity already is
I did the potion effect and have a few glitches and this is what I started on the placing ice block ..
UPDATE:
#getCollisionBoundingBoxFromPool seems to work and can pretty closedly put on the target
I will post again after I fix a few things
public class LiquidIceBlock extends Block {
public String blockName;
private int thisBlockID;
/* @Override
public int tickRate(){
return 30;
}*/
@Override
public void onBlockAdded(World world, int x, int y, int z){
super.onBlockAdded(world, x, y, z);
{
world.scheduleBlockUpdate(x, y, z, this, 30);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
super.updateTick(world, x, y, z, random);
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y, z, Blocks.water);
}
For finding the rounded block coordinates of the entity, this list of tips by Jabelar suggests something like this method. It doesn't do exactly what you want but, most importantly, it provides the math you need:
public Block findBlockUnderEntity(Entity parEntity)
{
int blockX = MathHelper.floor_double(parEntity.posX);
int blockY = MathHelper.floor_double(parEntity.boundingBox.minY) - 1;
int blockZ = MathHelper.floor_double(parEntity.posZ);
return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
}
Of course, to get or set the block the Entity is "in" you would add one to the blockY.
As far as I know, the World#setBlock method does not check for Entity collisions before setting the Block. You should be just fine to set it directly at the Entity's location.
If that's not the case, I'm at a loss.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
}
/* @Override
public int tickRate(){
return 30;
}*/
public void onBlockAdded(World world, int x, int y, int z)
{
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y, z, BlockRegistry.liquidIce);
}
/* public void onNeighborBlockChange(World world, int x, int y, int z, int l)
{
world.scheduleBlockUpdate(x, y, z, this, tickRate());
}*/
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
super.updateTick(world, x, y, z, random);
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y + 1, z, Blocks.ice);
world.setBlock(x + 1, y, z, Blocks.ice);
world.setBlock(x - 1, y, z, Blocks.ice);
world.setBlock(x, y, z, BlockRegistry.liquidIce);
world.setBlock(x, y, z + 1, Blocks.snow_layer);
world.setBlock(x, y, z - 1, Blocks.ice);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int blockX, int blockY, int blockZ) {
return AxisAlignedBB.getBoundingBox(blockX, blockY, blockZ, blockX + 1, (double) blockY + 0.99 , blockZ + 1);
}
/* public Block findBlockUnderEntity(Entity entity, IBlockAccess world)
{
int blockX = MathHelper.floor_double(entity.posX);
int blockY = MathHelper.floor_double(entity.boundingBox.minY) - 1;
int blockZ = MathHelper.floor_double(entity.posZ);
Block block = entity.worldObj.getBlock(blockX, blockY, blockZ);
if (block.isReplaceable(world, blockX, blockY, blockZ))
{
((World) world).setBlock(blockX, blockY + 1, blockZ, BlockRegistry.liquidIce);
}
return entity.worldObj.getBlock(blockX, blockY, blockZ);
}*/
@Override
public void onEntityCollidedWithBlock( World world, int x, int y, int z, Entity entity ) {
//adds potion effect to mobs/ target
if (entity instanceof EntityLiving) {
((EntityLiving)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
}
//adds potion effect to player/target
else if (entity instanceof EntityLivingBase){
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_,
int p_149719_4_) {
public MightyIceSword(Item ToolMaterial, String textureName)
{
super(Item.ToolMaterial.STONE);
this.setUnlocalizedName(textureName);
this.setTextureName("MightySword");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(GlistreMod.MODID +":" + "MightySword");
}
@Override
//@SideOnly(Side.CLIENT)
public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List list){
ItemStack enchant01 = new ItemStack(ItemRegistry.MightySword);
enchant01.addEnchantment(Enchantment.smite, 1);
list.add(enchant01);
}
@Override
//@SideOnly(Side.CLIENT)
/** Makes your Item Enchanted when it is crafted */
public void onCreated(ItemStack item, World world, EntityPlayer player)
{
item.addEnchantment(Enchantment.sharpness, 2);
// Replace the "." after second "Enchantment" to see options
// The number is the Enchantment Level
}
//adds particle effects to Item
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player)
{
float var4 = 1.0F;
int i = (int)(player.prevPosX + (player.posX - player.prevPosX) * (double)var4);
int j = (int)(player.prevPosY + (player.posY - player.prevPosY) * (double)var4);
int k = (int)(player.prevPosZ + (player.posZ - player.prevPosZ) * (double)var4);
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10)
{
//x, y, and z coordinates. Mess around with them by adding or subtracting to move where the block places.
Pretty good outcome : so you right click and throw a snowball with ice chill sound effect and hits mob with a slowness potion ; also slowness when you attack onItemUse and adds a short speed boost to the player
then you zoom in and place an ice block which adds slowness via # onEntityCollideWithBlock (if not there already) then it expands into several ice blocks after thirty ticks. It works to stop mobs if you quickly surround it but probably would not stop a player just slow them down a bit
has a crackling ice effect when the ice surrounds the mob
could not really get setBlockBounds to help much I just went with regular ice blocks and snow
also could not really figure out how the findBlockUnderEntity would help it seems to place blocks no problem without it
Could improve this if I could figure out how to make all the blocks disappear afterwards, but since it is already updating the blocks with # updateTick not sure how to "re-update" them ?
Needing suggestions on how I could make a freezing effect on an item sword? I could add a strong snowball throw? Place ice block onItemRightClick?
Instead of lighting an entity target on fire I want to create ice and slowness effect on the target....
Giving potion effect Slowness III or more keeps them from moving. You could also have it place an ice block (not packed ice, regular) at the entity's position.
You could also create a new TileEntity / Block that you are able to walk through. I have done this with a "liquid" that isn't supposed to flow / be an actual liquid. Then when you send the packet to slow the entity, also have it place the block where they are standing and one above that. In the TE of the blocks that are placed, it would count to their melt point and then make them disappear.
You could also get more creative and make the blocks no full 3d cubes. Make them partial block size just enough to surround the player.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Instead of a Tile Entity, you could call Block#setTickRandomly(true) in the constructor and make the block disappear in the Block#updateTick. However, this means the blocks will stay for 3 to 10 seconds before disappearing instead of lasting an exact amount of time.
Making blocks non-full cubes is very easy in 1.7.10, by calling Block#setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ).
Making blocks not do collisions is easy in both 1.7.10 and 1.8.
I didn't think packets were necessary to give potion effects... Just call EntityLiving#addPotionEffect.
Much appreciated on all these great ideas. Planning to work on it and I will post some results.
How would you place the block at the entity's position? every thing I have tried allows me to put block's everywhere BUT the entity position ...ie,, I can surround the entity , etc. but even if I make my block material water, lava , or air I cannot put it where the entity already is
I did the potion effect and have a few glitches and this is what I started on the placing ice block ..
UPDATE:
#getCollisionBoundingBoxFromPool seems to work and can pretty closedly put on the target
I will post again after I fix a few things
public class LiquidIceBlock extends Block {
public String blockName;
private int thisBlockID;
public LiquidIceBlock(int harvestLevel) {
super(Material.ice);
this.setBlockName(blockName);
// this.setBlockBounds(0.5F, 0.5F, 0.5F, 1.0F, 1.0F, 1.0F);
this.setTickRandomly(true);
}
/* @Override
public int tickRate(){
return 30;
}*/
@Override
public void onBlockAdded(World world, int x, int y, int z){
super.onBlockAdded(world, x, y, z);
{
world.scheduleBlockUpdate(x, y, z, this, 30);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
super.updateTick(world, x, y, z, random);
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y, z, Blocks.water);
}
For finding the rounded block coordinates of the entity, this list of tips by Jabelar suggests something like this method. It doesn't do exactly what you want but, most importantly, it provides the math you need:
Of course, to get or set the block the Entity is "in" you would add one to the blockY.
As far as I know, the World#setBlock method does not check for Entity collisions before setting the Block. You should be just fine to set it directly at the Entity's location.
If that's not the case, I'm at a loss.
cheers
thanks for the quick response
will get back to this soon
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockIce;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class LiquidIceBlock extends BlockIce {
public String blockName;
public LiquidIceBlock() {
super();
this.setBlockName(blockName);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, .99F, 1.0F);
this.setTickRandomly(true);
}
/* @Override
public int tickRate(){
return 30;
}*/
public void onBlockAdded(World world, int x, int y, int z)
{
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y, z, BlockRegistry.liquidIce);
}
/* public void onNeighborBlockChange(World world, int x, int y, int z, int l)
{
world.scheduleBlockUpdate(x, y, z, this, tickRate());
}*/
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
super.updateTick(world, x, y, z, random);
world.scheduleBlockUpdate(x, y, z, this, 30);
world.setBlock(x, y + 1, z, Blocks.ice);
world.setBlock(x + 1, y, z, Blocks.ice);
world.setBlock(x - 1, y, z, Blocks.ice);
world.setBlock(x, y, z, BlockRegistry.liquidIce);
world.setBlock(x, y, z + 1, Blocks.snow_layer);
world.setBlock(x, y, z - 1, Blocks.ice);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int blockX, int blockY, int blockZ) {
return AxisAlignedBB.getBoundingBox(blockX, blockY, blockZ, blockX + 1, (double) blockY + 0.99 , blockZ + 1);
}
/* public Block findBlockUnderEntity(Entity entity, IBlockAccess world)
{
int blockX = MathHelper.floor_double(entity.posX);
int blockY = MathHelper.floor_double(entity.boundingBox.minY) - 1;
int blockZ = MathHelper.floor_double(entity.posZ);
Block block = entity.worldObj.getBlock(blockX, blockY, blockZ);
if (block.isReplaceable(world, blockX, blockY, blockZ))
{
((World) world).setBlock(blockX, blockY + 1, blockZ, BlockRegistry.liquidIce);
}
return entity.worldObj.getBlock(blockX, blockY, blockZ);
}*/
@Override
public void onEntityCollidedWithBlock( World world, int x, int y, int z, Entity entity ) {
//adds potion effect to mobs/ target
if (entity instanceof EntityLiving) {
((EntityLiving)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
}
//adds potion effect to player/target
else if (entity instanceof EntityLivingBase){
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_,
int p_149719_4_) {
super.setBlockBoundsBasedOnState(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_);
}
}
Ice Sword
package com.glistre.glistremod.items;
import java.util.List;
import java.util.Random;
import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.blocks.BlockRegistry;
import com.glistre.glistremod.entities.EntityIcePotionBall;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class MightyIceSword extends ItemSword {
private String texturePath = "com.glistre.glistremod:";
public MightyIceSword(Item ToolMaterial, String textureName)
{
super(Item.ToolMaterial.STONE);
this.setUnlocalizedName(textureName);
this.setTextureName("MightySword");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(GlistreMod.MODID +":" + "MightySword");
}
@Override
//@SideOnly(Side.CLIENT)
public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List list){
ItemStack enchant01 = new ItemStack(ItemRegistry.MightySword);
enchant01.addEnchantment(Enchantment.smite, 1);
list.add(enchant01);
}
@Override
//@SideOnly(Side.CLIENT)
/** Makes your Item Enchanted when it is crafted */
public void onCreated(ItemStack item, World world, EntityPlayer player)
{
item.addEnchantment(Enchantment.sharpness, 2);
// Replace the "." after second "Enchantment" to see options
// The number is the Enchantment Level
}
//adds particle effects to Item
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player)
{
float var4 = 1.0F;
int i = (int)(player.prevPosX + (player.posX - player.prevPosX) * (double)var4);
int j = (int)(player.prevPosY + (player.posY - player.prevPosY) * (double)var4);
int k = (int)(player.prevPosZ + (player.posZ - player.prevPosZ) * (double)var4);
if(true){
if(player instanceof EntityLivingBase) ((EntityLivingBase)player).addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 2));
}
for (int l = 0; l < 8; ++l)
{
par2World.spawnEntityInWorld(new EntityIcePotionBall(par2World, player, l));
par2World.playSoundAtEntity(player, "glistremod:chill_hit", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);
}
//added to cure like milk
// player.curePotionEffects(new ItemStack (Items.milk_bucket));
// target.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 800, 10));
player.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10)
{
//x, y, and z coordinates. Mess around with them by adding or subtracting to move where the block places.
par3World.setBlock(x, y + 1, z, BlockRegistry.liquidIce);
par3World.playSoundAtEntity(par2EntityPlayer, "glistremod:fast_freezingice", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);
par2EntityPlayer.removePotionEffect(Potion.moveSlowdown.getId());
return true;
}
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase player)
{
target.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
return true;
}
}
Pretty good outcome : so you right click and throw a snowball with ice chill sound effect and hits mob with a slowness potion ; also slowness when you attack onItemUse and adds a short speed boost to the player
then you zoom in and place an ice block which adds slowness via # onEntityCollideWithBlock (if not there already) then it expands into several ice blocks after thirty ticks. It works to stop mobs if you quickly surround it but probably would not stop a player just slow them down a bit
has a crackling ice effect when the ice surrounds the mob
could not really get setBlockBounds to help much I just went with regular ice blocks and snow
also could not really figure out how the findBlockUnderEntity would help it seems to place blocks no problem without it
Could improve this if I could figure out how to make all the blocks disappear afterwards, but since it is already updating the blocks with # updateTick not sure how to "re-update" them ?
Thanks for the help!
thanks