Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.12.2-forge' into 1.14.4-forge
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Dec 22, 2023
2 parents ba99a03 + 3fc7f9d commit a4ed0a7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cam72cam/mod/ModCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/cam72cam/mod/block/BlockType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cam72cam/mod/block/IBlockTypeBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cam72cam.mod.block;

public interface IBlockTypeBlock {
BlockType getType();
}
8 changes: 8 additions & 0 deletions src/main/java/cam72cam/mod/world/IBlockEntityCollision.java
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 2 additions & 2 deletions src/main/java/cam72cam/mod/world/IConditionalCollision.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);

}
19 changes: 15 additions & 4 deletions src/main/java/cam72cam/mod/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a4ed0a7

Please sign in to comment.