Résolu Modifier la vitesse d'une echelle
-
Re Bonsoir , sais encore moi je voudrais modifier la vitesse d’une échelle mais je sais pas quoi changer pour arriver a sa
voila la classe de l’échelle :
merci
:::
import cpw.mods.fml.relauncher.Side;import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;import net.minecraftforge.common.util.ForgeDirection;
import static net.minecraftforge.common.util.ForgeDirection.*;public class BlockLadder extends Block
{
private static final String __OBFID = “CL_00000262”;protected BlockLadder()
{
super(Material.circuits);
this.setCreativeTab(CreativeTabs.tabDecorations);
}/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}public void func_149797_b(int p_149797_1_)
{
float f = 0.125F;if (p_149797_1_ == 2)
{
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}if (p_149797_1_ == 3)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}if (p_149797_1_ == 4)
{
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}if (p_149797_1_ == 5)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}/**
* If this block doesn’t render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 8;
}/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
{
return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST ) ||
p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST ) ||
p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH) ||
p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH);
}/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_;if ((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH))
{
j1 = 2;
}if ((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH))
{
j1 = 3;
}if ((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST))
{
j1 = 4;
}if ((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST))
{
j1 = 5;
}return j1;
}/**
* Lets the block know when one of its neighbor changes. Doesn’t know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor Block
*/
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
boolean flag = false;if (l == 2 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH))
{
flag = true;
}if (l == 3 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH))
{
flag = true;
}if (l == 4 && p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST))
{
flag = true;
}if (l == 5 && p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST))
{
flag = true;
}if (!flag)
{
this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
}super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
}/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random p_149745_1_)
{
return 1;
}@Override
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
}
::: -
À mon avis il faudrait passer par l’event PlayerTick, si le joueur est sur un échelle tu accélère son motionY.
-
Bonjours merci pour ta réponse mais je voudrais crée une nouvelle échelle est celle la aura une vitesse plus rapide que celle de minecraft .
je sais pas si on pourrais ajouter onEntityCollidedWithBlock .
-
Essayes, si ça ne fonctionne pas passe par l’event de tick du joueur.
-
J’ai essayer plusieurs truc comme :
public void onEntityCollidedWithBlock(double par1, int par2, int par3, int par4, Entity par5){
if par5.onEntityUpdate();
{
par5.setVelocity(par1, par3, getMobilityFlag(5));
}
}private double getMobilityFlag(double d) {
// TODO Auto-generated method stub
return 0;
}
}mais sais pas très concluant j’ai mis :if par5.onEntityUpdate();
car si je le mets pas sa ferrait monté automatiquement -
@‘FairyOne’:
sa fessait monté
-> accent portugais spotted !
@‘FairyOne’:
J’ai essayer plusieurs truc comme :
public void onEntityCollidedWithBlock(double par1, int par2, int par3, int par4, Entity par5){
if par5.onEntityUpdate();
{
par5.setVelocity(par1, par3, getMobilityFlag(5));
}
}private double getMobilityFlag(double d) {
// TODO Auto-generated method stub
return 0;
}
}mais sais pas très concluant j’ai mis :if par5.onEntityUpdate();
car si je le mets pas sa fessait monté automatiquementC’est sûr que ton entitée risque pas de montée vu que la fonction onEntityUpdate est de type void… Il faut utiliser les touches de minecraft pour ça.
-
ok xD
sais quoi l’event pour la touche?
-
-
J’arrive pas avec a utiliser la touche .
-
@‘FairyOne’:
J’arrive pas avec a utiliser la touche .
Envoi ton code
-
voila :
:::
import static net.minecraftforge.common.util.ForgeDirection.EAST;import static net.minecraftforge.common.util.ForgeDirection.NORTH;
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
import static net.minecraftforge.common.util.ForgeDirection.WEST;import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;public class BaseVigne extends Block
{
private static final String __OBFID = “CL_00000262”;protected BaseVigne()
{
super(Material.circuits);
}/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}public void func_149797_b(int p_149797_1_)
{
float f = 0.125F;if (p_149797_1_ == 2)
{
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}if (p_149797_1_ == 3)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}if (p_149797_1_ == 4)
{
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}if (p_149797_1_ == 5)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}/**
* If this block doesn’t render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 8;
}/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
{
return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST ) ||
p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST ) ||
p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH) ||
p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH);
}/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_;if ((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH))
{
j1 = 2;
}if ((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH))
{
j1 = 3;
}if ((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST))
{
j1 = 4;
}if ((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST))
{
j1 = 5;
}return j1;
}/**
* Lets the block know when one of its neighbor changes. Doesn’t know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor Block
*/
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
boolean flag = false;if (l == 2 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH))
{
flag = true;
}if (l == 3 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH))
{
flag = true;
}if (l == 4 && p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST))
{
flag = true;
}if (l == 5 && p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST))
{
flag = true;
}if (!flag)
{
this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
}super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
}/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random p_149745_1_)
{
return 1;
}@Override
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
public void onEntityCollidedWithBlock(World par1, int par2, int par3, int par4, Entity par5)
{
par5.moveEntity(par1, getMobilityFlag(5), par5);
}private double getMobilityFlag(int i) {
// TODO Auto-generated method stub
return 0;
}
}
::: -
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
-
@‘robin4002’:
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
-
@‘SCAREX’:
@‘robin4002’:
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
Et si le joueur recule sur l échelle ?
Envoyé de mon GT-S7390G
-
@‘Diangle’:
@‘SCAREX’:
@‘robin4002’:
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
Et si le joueur recule sur l échelle ?
Envoyé de mon GT-S7390G
Dans le code de minecraft, pour descendre faut appuyer sur aucune touche. Après si tu veux totalement changer le gameplay, je te laisse jeter un coup d’oeil à toutes les touches dans Minecraft.getMinecraft().gameSettings.keyBindCeQueTuVeux et si tu veux un keyBind custom, il y a un tutoriel pour ça sur le forum.
-
@‘SCAREX’:
@‘Diangle’:
@‘SCAREX’:
@‘robin4002’:
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
Et si le joueur recule sur l échelle ?
Envoyé de mon GT-S7390G
Dans le code de minecraft, pour descendre faut appuyer sur aucune touche. Après si tu veux totalement changer le gameplay, je te laisse jeter un coup d’oeil à toutes les touches dans Minecraft.getMinecraft().gameSettings.keyBindCeQueTuVeux et si tu veux un keyBind custom, il y a un tutoriel pour ça sur le forum.
Non pas pour descendre xD Mais quand tu te met dos a une échelle et que tu appuis sur la touche de recule ^^
-
@‘Diangle’:
@‘SCAREX’:
@‘Diangle’:
@‘SCAREX’:
@‘robin4002’:
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { entity.motionY *= 1.1F; }
Comme ça ?
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
Et si le joueur recule sur l échelle ?
Envoyé de mon GT-S7390G
Dans le code de minecraft, pour descendre faut appuyer sur aucune touche. Après si tu veux totalement changer le gameplay, je te laisse jeter un coup d’oeil à toutes les touches dans Minecraft.getMinecraft().gameSettings.keyBindCeQueTuVeux et si tu veux un keyBind custom, il y a un tutoriel pour ça sur le forum.
Non pas pour descendre xD Mais quand tu te met dos a une échelle et que tu appuis sur la touche de recule ^^
J’arrive pas à trouver où le code est exécuté, il faut que tu cherches en profondeur de ton côté.
-
@‘SCAREX’:
@‘Diangle’:
@‘SCAREX’:
@‘Diangle’:
@‘SCAREX’:
Essaie avec çà :
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (Minecraft.getMinecraft().gameSettings.keyBindForward.isPressed()) entity.motionY *= 1.1F; }
Et si le joueur recule sur l échelle ?
Envoyé de mon GT-S7390G
Dans le code de minecraft, pour descendre faut appuyer sur aucune touche. Après si tu veux totalement changer le gameplay, je te laisse jeter un coup d’oeil à toutes les touches dans Minecraft.getMinecraft().gameSettings.keyBindCeQueTuVeux et si tu veux un keyBind custom, il y a un tutoriel pour ça sur le forum.
Non pas pour descendre xD Mais quand tu te met dos a une échelle et que tu appuis sur la touche de recule ^^
J’arrive pas à trouver où le code est exécuté, il faut que tu cherches en profondeur de ton côté.
Eh bien pour cela tu check soit la direction (Nord - Sud - Est ou Ouest) que le joueur regarde ou alors tu regardes si rotationYaw ou rotationPitch je ne sais plus est compris entre telle et telle valeur afin de faire en sorte qu il y ait une condition qui check si le joueur est de dos et puis en second tu check si la touche pour reculer est presse et si les deux conditions sont validées et bien tu changeras motionY comme l avait deja dit Scarex.
-
regarde les source du mod ender io il ajoute les dark steel ladder qui vont plus vite que celle de base =P
-
Voilà :
package fr.scarex.st18.ST18Blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockLadder; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import fr.scarex.st18.ST18; public class AdvancedLadder extends BlockLadder { private static final String name = "advanced_ladder"; public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); protected AdvancedLadder() { GameRegistry.registerBlock(this, name); setUnlocalizedName(ST18.MODID + "_" + name); } @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { if (entity.onGround || entity.isCollidedVertically) { return; } if (entity.motionY >= 0.1) { entity.setPosition(entity.posX, entity.posY + 1.0F, entity.posZ); } else if (entity.motionY <= -0.1) { Block blockUnder = world.getBlockState(new BlockPos(entity.posX, entity.posY - 3, entity.posZ)).getBlock(); if (blockUnder == null || blockUnder == this) { entity.setPosition(entity.posX, entity.posY - 1.0F, entity.posZ); } } } }
NOTES :
-ce code marche pour la 1.8, il faut modifier quelques trucs pour que ça fonctionne en 1.7.
-le 1.0F correspond à la vitesse voulue (ici 1.0F est très grand)