diff --git a/build.gradle b/build.gradle index 3e7e14b4..5dcc947c 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ repositories { mavenCentral() } -String umcVersion = "1.2.0" +String umcVersion = "1.2.1" if (!"release".equalsIgnoreCase(System.getProperty("target"))) { try { umcVersion += "-" + 'git rev-parse --verify --short=7 HEAD'.execute().text.trim() diff --git a/src/main/java/cam72cam/mod/ModCore.java b/src/main/java/cam72cam/mod/ModCore.java index f95514dc..28710df9 100644 --- a/src/main/java/cam72cam/mod/ModCore.java +++ b/src/main/java/cam72cam/mod/ModCore.java @@ -61,7 +61,7 @@ public class ModCore { public static final String MODID = "universalmodcore"; public static final String NAME = "UniversalModCore"; - public static final String VERSION = "1.2.0"; + public static final String VERSION = "1.2.1"; public static ModCore instance; public static boolean hasResources; private static boolean isInReload; diff --git a/src/main/java/cam72cam/mod/block/BlockType.java b/src/main/java/cam72cam/mod/block/BlockType.java index 7ebed6a2..16f39e24 100644 --- a/src/main/java/cam72cam/mod/block/BlockType.java +++ b/src/main/java/cam72cam/mod/block/BlockType.java @@ -145,7 +145,11 @@ public int getWeakPower(World world, Vec3i vec3i, Facing from) { * BlockInternal is an internal class that should only be extended when you need to implement * an interface. */ - protected class BlockInternal extends net.minecraft.block.Block { + protected class BlockInternal extends net.minecraft.block.Block implements IBlockTypeBlock { + public BlockType getType() { + return BlockType.this; + } + public BlockInternal() { super(Block.Properties.create(BlockType.this.getMaterial().internal) .sound(BlockType.this.getMaterial().soundType) diff --git a/src/main/java/cam72cam/mod/block/IBlockTypeBlock.java b/src/main/java/cam72cam/mod/block/IBlockTypeBlock.java new file mode 100644 index 00000000..f53fcaa1 --- /dev/null +++ b/src/main/java/cam72cam/mod/block/IBlockTypeBlock.java @@ -0,0 +1,5 @@ +package cam72cam.mod.block; + +public interface IBlockTypeBlock { + BlockType getType(); +} diff --git a/src/main/java/cam72cam/mod/world/IBlockEntityCollision.java b/src/main/java/cam72cam/mod/world/IBlockEntityCollision.java new file mode 100644 index 00000000..8536ab83 --- /dev/null +++ b/src/main/java/cam72cam/mod/world/IBlockEntityCollision.java @@ -0,0 +1,8 @@ +package cam72cam.mod.world; + +import cam72cam.mod.entity.Entity; +import cam72cam.mod.math.Vec3i; + +public interface IBlockEntityCollision { + boolean canCollide(World world, Vec3i pos, Entity entity); +} diff --git a/src/main/java/cam72cam/mod/world/IConditionalCollision.java b/src/main/java/cam72cam/mod/world/IConditionalCollision.java index 123bb37a..9876757b 100644 --- a/src/main/java/cam72cam/mod/world/IConditionalCollision.java +++ b/src/main/java/cam72cam/mod/world/IConditionalCollision.java @@ -1,7 +1,7 @@ package cam72cam.mod.world; import net.minecraft.block.BlockState; -import net.minecraft.util.DamageSource; +import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -21,6 +21,6 @@ public interface IConditionalCollision { * @param damageSource Damage source that would be used to collide with the block. * @return Whether or not to calculate actual collision. */ - boolean canCollide(World world, BlockPos pos, BlockState state, DamageSource damageSource); + boolean canCollide(World world, BlockPos pos, BlockState state, Entity entity); } diff --git a/src/main/java/cam72cam/mod/world/World.java b/src/main/java/cam72cam/mod/world/World.java index 0c17ae34..d398d472 100644 --- a/src/main/java/cam72cam/mod/world/World.java +++ b/src/main/java/cam72cam/mod/world/World.java @@ -4,6 +4,7 @@ import cam72cam.mod.ModCore; import cam72cam.mod.block.BlockEntity; import cam72cam.mod.block.BlockType; +import cam72cam.mod.block.IBlockTypeBlock; import cam72cam.mod.block.tile.TileEntity; import cam72cam.mod.entity.Entity; import cam72cam.mod.entity.Living; @@ -658,10 +659,20 @@ public void setBlock(Vec3i pos, BlockInfo info) { } /** Opt in collision overriding */ - public boolean canEntityCollideWith(Vec3i bp, String damageType) { - Block block = internal.getBlockState(bp.internal()).getBlock(); - return ! (block instanceof IConditionalCollision) || - ((IConditionalCollision) block).canCollide(internal, bp.internal(), internal.getBlockState(bp.internal()), new DamageSource(damageType)); + public boolean canEntityCollideWith(Vec3i bp, Entity entity) { + BlockState state = internal.getBlockState(bp.internal()); + Block block = state.getBlock(); + + if (block instanceof IConditionalCollision && ((IConditionalCollision) block).canCollide(internal, bp.internal(), state, entity.internal)) + return true; + + if (block instanceof IBlockTypeBlock) { + BlockType type = ((IBlockTypeBlock) block).getType(); + if (type instanceof IBlockEntityCollision) { + return ((IBlockEntityCollision) type).canCollide(this, bp, entity); + } + } + return false; } /** Spawn a particle */