Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.11.2-forge' into 1.10.2-forge
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Dec 22, 2023
2 parents b498955 + 0ed6a9f commit ed767d9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
}
}

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 @@ -50,7 +50,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;

private List<Mod> mods = new ArrayList<>();
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 @@ -142,7 +142,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(BlockType.this.getMaterial().internal);
BlockType type = BlockType.this;
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);
}
3 changes: 2 additions & 1 deletion src/main/java/cam72cam/mod/world/IConditionalCollision.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cam72cam.mod.world;

import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -21,6 +22,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, IBlockState state, DamageSource damageSource);
boolean canCollide(World world, BlockPos pos, IBlockState 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.*;
import cam72cam.mod.entity.boundingbox.BoundingBox;
Expand Down Expand Up @@ -632,10 +633,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) {
IBlockState 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
16 changes: 16 additions & 0 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"modid": "universalmodcore",
"name": "UniversalModCore",
"description": "Universal Mod Core",
"version": "1.2.1",
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",
"authorList": [],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

0 comments on commit ed767d9

Please sign in to comment.