diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java index 734d669ea..0d33dee1c 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThermalDetonatorEntity.java @@ -81,11 +81,13 @@ protected void onCollision(HitResult hitResult) if (hitResult.getType() == HitResult.Type.BLOCK) { + BlockHitResult blockHitResult = (BlockHitResult)hitResult; + /* if (hitResult.squaredDistanceTo(this) < 0.01) { this.setVelocity(0, 0, 0); } - BlockHitResult blockHitResult = (BlockHitResult)hitResult; + Vec3d velocity = this.getVelocity(); Vec3d pos = hitResult.getPos(); @@ -149,6 +151,8 @@ else if (this.getX() - pos.getX() > 0 && this.getZ() - pos.getZ() < 0) } } this.setVelocity(velocity.x * modX, velocity.y * modY, velocity.z * modZ); + */ + this.deflect(blockHitResult); } super.onCollision(hitResult); } diff --git a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java index 007e89543..8ecd5e945 100644 --- a/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java +++ b/projects/pswg/src/main/java/com/parzivail/pswg/entity/ThrowableExplosive.java @@ -4,7 +4,9 @@ import com.parzivail.pswg.container.SwgTags; import com.parzivail.util.entity.IPrecisionSpawnEntity; import com.parzivail.util.entity.IPrecisionVelocityEntity; +import com.parzivail.util.math.MathUtil; import com.parzivail.util.network.PreciseEntitySpawnS2CPacket; +import net.minecraft.block.BlockState; import net.minecraft.entity.EntityType; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageTypes; @@ -16,6 +18,11 @@ import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.registry.tag.DamageTypeTags; import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.Text; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.explosion.ExplosionBehavior; @@ -28,6 +35,7 @@ public abstract class ThrowableExplosive extends ThrownEntity implements IPrecis boolean shouldExplode= false; float explosionPower =5f; public boolean shouldRenderVar = true; + boolean gravity=true; protected ThrowableExplosive(EntityType entityType, World world) { @@ -44,6 +52,46 @@ public void onSpawnPacket(EntitySpawnS2CPacket packet) this.readSpawnData(pes.getData()); } } + protected void deflect(HitResult hit) + { + var velocity = this.getVelocity(); + BlockHitResult blockHit = (BlockHitResult)hit; + + if (blockHit.getSide().equals(Direction.UP)) + { + if (hit.squaredDistanceTo(this)<0.01) + { + stopMovement(); + }else{ + velocity=velocity.multiply(0.75f,-0.2 ,0.75f); + this.setVelocity(velocity); + } + }else + { + var dir = velocity.normalize(); + + var normal = new Vec3d(blockHit.getSide().getUnitVector()); + var newDir = MathUtil.reflect(dir, normal); + this.setVelocity(newDir.multiply(velocity.length() * 0.5f)); + } + } + protected void stopMovement(){ + this.setVelocity(0f,0f,0f); + gravity=false; + + } + + @Override + protected float getGravity() + { + if(gravity) + { + return super.getGravity(); + }else{ + return 0f; + } + } + @Override public void tick() { diff --git a/projects/pswg/src/main/resources/assets/pswg/textures/item/model/thermal_detonator/thermal_detonator_primed.png.mcmeta b/projects/pswg/src/main/resources/assets/pswg/textures/item/model/thermal_detonator/thermal_detonator_primed.png.mcmeta index 0b83816b0..45f6fb941 100644 --- a/projects/pswg/src/main/resources/assets/pswg/textures/item/model/thermal_detonator/thermal_detonator_primed.png.mcmeta +++ b/projects/pswg/src/main/resources/assets/pswg/textures/item/model/thermal_detonator/thermal_detonator_primed.png.mcmeta @@ -1,6 +1,6 @@ { "animation": { "interpolate": true, - "frametime": 4 + "frametime": 3 } } diff --git a/projects/pswg/src/main/resources/data/pswg/tags/blocks/detonator_explode.json b/projects/pswg/src/main/resources/data/pswg/tags/blocks/detonator_explode.json index 66d065c7d..3e73424d8 100644 --- a/projects/pswg/src/main/resources/data/pswg/tags/blocks/detonator_explode.json +++ b/projects/pswg/src/main/resources/data/pswg/tags/blocks/detonator_explode.json @@ -52,8 +52,11 @@ "minecraft:crimson_roots", "minecraft:frogspawn", "minecraft:torch", +"minecraft:wall_torch", "minecraft:soul_torch", +"minecraft:soul_wall_torch", "minecraft:redstone_torch", +"minecraft:redstone_wall_torch", "minecraft:kelp", "minecraft:end_rod", "minecraft:hanging_roots", @@ -81,6 +84,22 @@ "minecraft:brewing_stand", "minecraft:lever", "minecraft:tripwire_hook", +"pswg:dried_poonten_grass", +"pswg:poonten_grass", +"pswg:funnel_flower", +"pswg:blossoming_funnel_flower", +"pswg:hkak_bush", +"pswg:tuber_stalk", +"pswg:vaporator_mushroom_colony", +"pswg:scaffold", +"pswg:scaffold_stairs", +"pswg:red_hangar_light", +"pswg:blue_hangar_light", +"pswg:tall_lamp", +"pswg:molo_shrub", +"pswg:power_coupling", +"pswg:wall_cluster_light", +"pswg:electrostatic_repeller", "#minecraft:crops", "#minecraft:doors", "#minecraft:fences", @@ -97,5 +116,6 @@ "#minecraft:wool_carpets", "#minecraft:candles", "#minecraft:banners", +"#minecraft:fence_gates", "#c:buds" ]}