Skip to content

Commit

Permalink
Merge branch 'refs/heads/multiloader' into 1.19.2/multiloader
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed Jun 19, 2024
2 parents cb49ebf + 47c6fa3 commit 1524259
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.3.4 - 2024-06-19

## Fixed

- Multistate copycats having much lower friction than normal

## 1.3.3 - 2024-06-18

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
Expand Down Expand Up @@ -72,14 +73,18 @@ public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
@Override
public float getFriction(BlockState state, LevelReader level, BlockPos pos, Entity entity) {
if (state.getBlock() instanceof MultiStateCopycatBlock mscb) {
AtomicReference<Float> bonus = new AtomicReference<>(state.getBlock().getFriction());
AtomicReference<Float> bonus = new AtomicReference<>(0f);
AtomicInteger count = new AtomicInteger(0);
mscb.withBlockEntityDo(level, pos, mscbe -> mscbe.getMaterialItemStorage()
.getAllMaterials().forEach(mat -> {
bonus.set(bonus.get() + maybeMaterialAs(level, pos, CustomFrictionBlock.class,
count.getAndIncrement();
bonus.accumulateAndGet(maybeMaterialAs(level, pos, CustomFrictionBlock.class,
mat, (material, frictionBlock) -> frictionBlock.getFriction(material, level, pos, entity),
(material) -> 0f));
(material) -> material.is(Blocks.AIR)
? state.getBlock().getFriction()
: material.getBlock().getFriction()), Float::sum);
}));
return bonus.get();
return bonus.get() / count.get();
}
return state.getBlock().getFriction();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
Expand Down Expand Up @@ -43,9 +44,13 @@ public SoundType getSoundType(BlockState state, LevelReader level, BlockPos pos,
@Override
public float getFriction(BlockState state, LevelReader level, BlockPos pos, Entity entity) {
if (state.getBlock() instanceof MultiStateCopycatBlock mscb) {
AtomicReference<Float> bonus = new AtomicReference<>(state.getBlock().getFriction());
mscb.withBlockEntityDo(level, pos, mscbe -> mscbe.getMaterialItemStorage().getAllMaterials().forEach(mat -> bonus.set(bonus.get() + mat.getFriction(level, pos, entity))));
return bonus.get();
AtomicReference<Float> bonus = new AtomicReference<>(0f);
AtomicInteger count = new AtomicInteger(0);
mscb.withBlockEntityDo(level, pos, mscbe -> mscbe.getMaterialItemStorage().getAllMaterials().forEach(mat -> {
count.getAndIncrement();
bonus.accumulateAndGet(mat.is(Blocks.AIR) ? state.getFriction(level, pos, entity) : mat.getFriction(level, pos, entity), Float::sum);
}));
return bonus.get() / count.get();
}
return state.getBlock().getFriction();
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G

#Mod
archives_base_name=Copycats
mod_version=1.3.3
mod_version=1.3.4
maven_group=com.copycatsplus
mod_authors=Lysine, Bennyboy1695, Redcat_XVIII
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
Expand Down

0 comments on commit 1524259

Please sign in to comment.