improve bullet physics
This commit is contained in:
parent
fcc5e9b640
commit
d566db0fc5
7 changed files with 38 additions and 4 deletions
|
@ -1008,4 +1008,8 @@ public class Block {
|
||||||
|
|
||||||
public void onDestroyedByFire(World world, BlockPos pos, State state) {
|
public void onDestroyedByFire(World world, BlockPos pos, State state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
|
||||||
|
return this.material.blocksMovement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package common.block.artificial;
|
||||||
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.Material;
|
import common.block.Material;
|
||||||
|
import common.entity.Entity;
|
||||||
import common.item.CheatTab;
|
import common.item.CheatTab;
|
||||||
import common.model.BlockLayer;
|
import common.model.BlockLayer;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
|
@ -9,6 +10,7 @@ import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
import common.world.World;
|
||||||
|
|
||||||
public class BlockGlass extends Block {
|
public class BlockGlass extends Block {
|
||||||
public BlockGlass() {
|
public BlockGlass() {
|
||||||
|
@ -41,4 +43,9 @@ public class BlockGlass extends Block {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
return world.getState(pos.offset(side.getOpposite())) != state || (block != this && super.shouldSideBeRendered(world, pos, side));
|
return world.getState(pos.offset(side.getOpposite())) != state || (block != this && super.shouldSideBeRendered(world, pos, side));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
|
||||||
|
world.destroyBlock(pos, true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,12 @@ public class BlockPane extends Block
|
||||||
public boolean isMagnetic() {
|
public boolean isMagnetic() {
|
||||||
return this.material == Material.SOLID;
|
return this.material == Material.SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
|
||||||
|
if(this.material != Material.SOLID)
|
||||||
|
world.destroyBlock(pos, true);
|
||||||
|
return this.material == Material.SOLID;
|
||||||
|
}
|
||||||
|
|
||||||
protected String getPaneBase(State state) {
|
protected String getPaneBase(State state) {
|
||||||
return "glass";
|
return "glass";
|
||||||
|
|
|
@ -2,6 +2,7 @@ package common.block.artificial;
|
||||||
|
|
||||||
import common.block.BlockDirectional;
|
import common.block.BlockDirectional;
|
||||||
import common.block.Material;
|
import common.block.Material;
|
||||||
|
import common.entity.Entity;
|
||||||
import common.entity.types.EntityLiving;
|
import common.entity.types.EntityLiving;
|
||||||
import common.init.Items;
|
import common.init.Items;
|
||||||
import common.item.Item;
|
import common.item.Item;
|
||||||
|
@ -66,4 +67,9 @@ public class BlockSkull extends BlockDirectional {
|
||||||
public boolean isXrayVisible() {
|
public boolean isXrayVisible() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
|
||||||
|
world.destroyBlock(pos, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,15 @@ package common.block.natural;
|
||||||
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.Material;
|
import common.block.Material;
|
||||||
|
import common.entity.Entity;
|
||||||
import common.init.Items;
|
import common.init.Items;
|
||||||
import common.item.CheatTab;
|
import common.item.CheatTab;
|
||||||
import common.item.Item;
|
import common.item.Item;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
|
import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
import common.world.World;
|
||||||
|
|
||||||
public class BlockGlowstone extends Block
|
public class BlockGlowstone extends Block
|
||||||
{
|
{
|
||||||
|
@ -40,6 +43,11 @@ public class BlockGlowstone extends Block
|
||||||
{
|
{
|
||||||
return Items.glowstone_dust;
|
return Items.glowstone_dust;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
|
||||||
|
world.destroyBlock(pos, true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Get the MapColor for this Block and the given BlockState
|
// * Get the MapColor for this Block and the given BlockState
|
||||||
|
|
|
@ -16,6 +16,7 @@ import common.util.ExtMath;
|
||||||
import common.util.HitPosition;
|
import common.util.HitPosition;
|
||||||
import common.util.Vec3;
|
import common.util.Vec3;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityBullet extends Entity implements IProjectile, IObjectData
|
public class EntityBullet extends Entity implements IProjectile, IObjectData
|
||||||
|
@ -286,9 +287,11 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.playSound(SoundEvent.METALHIT, 0.5F);
|
State state = movingobjectposition.block != null ? this.worldObj.getState(movingobjectposition.block) : null;
|
||||||
|
if(state == null || state.getBlock().onShot(this.worldObj, movingobjectposition.block, state, this)) {
|
||||||
this.setDead();
|
this.playSound(SoundEvent.METALHIT, 0.5F);
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ public abstract class ItemRegistry {
|
||||||
registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128));
|
registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128));
|
||||||
registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte")
|
registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte")
|
||||||
.setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.MISC));
|
.setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.MISC));
|
||||||
registerItem((new ItemSmallBlock(Blocks.skull)).setDisplay("Schädel"));
|
registerItem((new ItemSmallBlock(Blocks.skull)).setDisplay("Schädel").setTab(CheatTab.DECORATION));
|
||||||
registerItem("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute"));
|
registerItem("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute"));
|
||||||
registerItem("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA));
|
registerItem("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA));
|
||||||
registerItem("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.MISC));
|
registerItem("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.MISC));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue