Skip to content

Commit

Permalink
Merge pull request #77 from Faboslav/1.19.3
Browse files Browse the repository at this point in the history
1.19.3
  • Loading branch information
Faboslav authored Dec 14, 2022
2 parents 302fc4d + 2dd3e75 commit 8be8d0e
Show file tree
Hide file tree
Showing 69 changed files with 574 additions and 443 deletions.
1 change: 1 addition & 0 deletions .github/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"1.19.3": "1.7.0",
"1.19.2": "1.6.3",
"1.19.1": "1.6.3",
"1.19": "1.6.3",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## mc1.19.3-1.7.0, December 14, 2022

- Ported to 1.19.3

## mc1.19.2-1.6.3, December 04, 2022

- Fixed server crash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static void init() {
public static void postInit() {
FriendsAndFoesBlocks.postInit();
FriendsAndFoesEntityTypes.postInit();
FriendsAndFoesItems.postInit();
FriendsAndFoesBlockEntityTypes.postInit();
FriendsAndFoesStructureProcessorTypes.postInit();
FriendsAndFoesVillagerProfessions.postInit();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faboslav.friendsandfoes.block;

import net.minecraft.block.AbstractButtonBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.ButtonBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
Expand All @@ -15,17 +15,15 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class CopperButtonBlock extends AbstractButtonBlock
public class CopperButtonBlock extends ButtonBlock
{
public static final int PRESS_TICKS = 10;

public CopperButtonBlock(Settings settings) {
super(false, settings);
public CopperButtonBlock(Settings settings, int pressTicks) {
super(settings, pressTicks, false, SoundEvents.BLOCK_STONE_BUTTON_CLICK_OFF, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON);
}

@Override
public SoundEvent getClickSound(boolean powered) {
return powered ? SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON:SoundEvents.BLOCK_STONE_BUTTON_CLICK_OFF;
return super.getClickSound(powered);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@
@SuppressWarnings({"rawtypes", "unchecked"})
public interface Oxidizable extends net.minecraft.block.Oxidizable
{
Supplier<BiMap<Block, Block>> OXIDATION_LEVEL_INCREASES = Suppliers.memoize(() -> {
return (BiMap) ImmutableBiMap.builder()
.put(FriendsAndFoesBlocks.COPPER_BUTTON.get(), FriendsAndFoesBlocks.EXPOSED_COPPER_BUTTON.get())
.put(FriendsAndFoesBlocks.EXPOSED_COPPER_BUTTON.get(), FriendsAndFoesBlocks.WEATHERED_COPPER_BUTTON.get())
.put(FriendsAndFoesBlocks.WEATHERED_COPPER_BUTTON.get(), FriendsAndFoesBlocks.OXIDIZED_COPPER_BUTTON.get())
.put(Blocks.LIGHTNING_ROD, FriendsAndFoesBlocks.EXPOSED_LIGHTNING_ROD.get())
.put(FriendsAndFoesBlocks.EXPOSED_LIGHTNING_ROD.get(), FriendsAndFoesBlocks.WEATHERED_LIGHTNING_ROD.get())
.put(FriendsAndFoesBlocks.WEATHERED_LIGHTNING_ROD.get(), FriendsAndFoesBlocks.OXIDIZED_LIGHTNING_ROD.get())
.build();
});
Supplier<BiMap<Block, Block>> OXIDATION_LEVEL_DECREASES = Suppliers.memoize(() -> {
return ((BiMap) OXIDATION_LEVEL_INCREASES.get()).inverse();
});
Supplier<BiMap<Block, Block>> OXIDATION_LEVEL_INCREASES = Suppliers.memoize(() -> (BiMap) ImmutableBiMap.builder()
.put(FriendsAndFoesBlocks.COPPER_BUTTON.get(), FriendsAndFoesBlocks.EXPOSED_COPPER_BUTTON.get())
.put(FriendsAndFoesBlocks.EXPOSED_COPPER_BUTTON.get(), FriendsAndFoesBlocks.WEATHERED_COPPER_BUTTON.get())
.put(FriendsAndFoesBlocks.WEATHERED_COPPER_BUTTON.get(), FriendsAndFoesBlocks.OXIDIZED_COPPER_BUTTON.get())
.put(Blocks.LIGHTNING_ROD, FriendsAndFoesBlocks.EXPOSED_LIGHTNING_ROD.get())
.put(FriendsAndFoesBlocks.EXPOSED_LIGHTNING_ROD.get(), FriendsAndFoesBlocks.WEATHERED_LIGHTNING_ROD.get())
.put(FriendsAndFoesBlocks.WEATHERED_LIGHTNING_ROD.get(), FriendsAndFoesBlocks.OXIDIZED_LIGHTNING_ROD.get())
.build());
Supplier<BiMap<Block, Block>> OXIDATION_LEVEL_DECREASES = Suppliers.memoize(() -> ((BiMap) OXIDATION_LEVEL_INCREASES.get()).inverse());

static Optional<Block> getDecreasedOxidationBlock(Block block) {
return Optional.ofNullable((Block) ((BiMap) OXIDATION_LEVEL_DECREASES.get()).get(block));
}

static Block getUnaffectedOxidationBlock(Block block) {
Block block2 = block;

for (Block block3 = (Block) ((BiMap) OXIDATION_LEVEL_DECREASES.get()).get(block); block3 != null; block3 = (Block) ((BiMap) OXIDATION_LEVEL_DECREASES.get()).get(block3)) {
block2 = block3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public final class OxidizableButtonBlock extends CopperButtonBlock implements Ox

public OxidizableButtonBlock(
OxidationLevel OxidationLevel,
Settings settings
Settings settings,
int pressTicks
) {
super(settings);
super(settings, pressTicks);
this.OxidationLevel = OxidationLevel;
}

Expand All @@ -31,7 +32,6 @@ public void randomTick(
BlockPos pos,
Random random
) {
super.randomTick(state, world, pos, random);
this.tickDegradation(state, world, pos, random);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import net.minecraft.block.BlockState;
import net.minecraft.block.LightningRodBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;

@SuppressWarnings("deprecation")
public final class OxidizableLightningRodBlock extends LightningRodBlock implements Oxidizable
{
private final OxidationLevel OxidationLevel;
Expand All @@ -19,22 +15,12 @@ public OxidizableLightningRodBlock(
this.OxidationLevel = OxidationLevel;
}

@Override
public void randomTick(
BlockState state,
ServerWorld world,
BlockPos pos,
Random random
) {
super.randomTick(state, world, pos, random);
this.tickDegradation(state, world, pos, random);
}

@Override
public boolean hasRandomTicks(BlockState state) {
return Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent();
}

@Override
public OxidationLevel getDegradationLevel() {
return this.OxidationLevel;
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.model.ModelPart;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Vec3d;

@Environment(EnvType.CLIENT)
public final class ModelAnimator
Expand Down Expand Up @@ -35,7 +35,7 @@ public void animatePositionWithProgress(
float targetZ,
float progress
) {
Vec3f targetVector = new Vec3f(targetX, targetY, targetZ);
Vec3d targetVector = new Vec3d(targetX, targetY, targetZ);
this.animateWithProgress(modelPart, ModelPartAnimationType.POSITION, targetVector, progress);
}

Expand All @@ -58,20 +58,20 @@ public void animateRotationWithProgress(
float targetZ,
float progress
) {
Vec3f targetVector = new Vec3f(targetX, targetY, targetZ);
Vec3d targetVector = new Vec3d(targetX, targetY, targetZ);
this.animateWithProgress(modelPart, ModelPartAnimationType.ROTATION, targetVector, progress);
}

private void animateWithProgress(
ModelPart modelPart,
ModelPartAnimationType animationType,
Vec3f targetVector,
Vec3d targetVector,
float progress
) {
String modelPartName = modelPart.toString();
ModelPartAnimationContext animationContext;
Vec3f animationCurrentVector;
Vec3f animationTargetVector;
Vec3d animationCurrentVector;
Vec3d animationTargetVector;

if (this.getAnimationContextTracker().contains(modelPartName, animationType)) {
animationContext = this.getAnimationContextTracker().get(modelPartName, animationType);
Expand All @@ -89,8 +89,8 @@ private void animateWithProgress(
}
} else {
animationCurrentVector = switch (animationType) {
case POSITION -> new Vec3f(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
case ROTATION -> new Vec3f(modelPart.pitch, modelPart.yaw, modelPart.roll);
case POSITION -> new Vec3d(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
case ROTATION -> new Vec3d(modelPart.pitch, modelPart.yaw, modelPart.roll);
};

animationContext = ModelPartAnimationContext.createWithProgress(
Expand Down Expand Up @@ -130,7 +130,7 @@ public void animatePositionOverTicks(
float targetZ,
int ticks
) {
Vec3f targetVector = new Vec3f(targetX, targetY, targetZ);
Vec3d targetVector = new Vec3d(targetX, targetY, targetZ);
this.animateOverTicks(modelPart, ModelPartAnimationType.POSITION, targetVector, ticks);
}

Expand All @@ -153,20 +153,20 @@ public void animateRotationOverTicks(
float targetZ,
int ticks
) {
Vec3f targetVector = new Vec3f(targetX, targetY, targetZ);
Vec3d targetVector = new Vec3d(targetX, targetY, targetZ);
this.animateOverTicks(modelPart, ModelPartAnimationType.ROTATION, targetVector, ticks);
}

private void animateOverTicks(
ModelPart modelPart,
ModelPartAnimationType animationType,
Vec3f targetVector,
Vec3d targetVector,
int ticks
) {
String modelPartName = modelPart.toString();
ModelPartAnimationContext animationContext;
Vec3f currentVector;
Vec3f animationTargetVector;
Vec3d currentVector;
Vec3d animationTargetVector;

if (this.getAnimationContextTracker().contains(modelPartName, animationType)) {
animationContext = this.getAnimationContextTracker().get(modelPartName, animationType);
Expand Down Expand Up @@ -195,8 +195,8 @@ private void animateOverTicks(
}
} else {
currentVector = switch (animationType) {
case POSITION -> new Vec3f(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
case ROTATION -> new Vec3f(modelPart.pitch, modelPart.yaw, modelPart.roll);
case POSITION -> new Vec3d(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
case ROTATION -> new Vec3d(modelPart.pitch, modelPart.yaw, modelPart.roll);
};

animationContext = ModelPartAnimationContext.createWithTicks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faboslav.friendsandfoes.util.animation.AnimationMath;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Vec3d;

@Environment(EnvType.CLIENT)
public final class ModelPartAnimationContext
Expand All @@ -12,17 +12,17 @@ public final class ModelPartAnimationContext
private final int totalTicks;
private int currentTick;

private final Vec3f targetVector;
private final Vec3f currentVector;
private final Vec3d targetVector;
private Vec3d currentVector;

private float progress;

private ModelPartAnimationContext(
int initialTick,
int totalTicks,
float progress,
Vec3f targetVector,
Vec3f currentVector
Vec3d targetVector,
Vec3d currentVector
) {
this.initialTick = initialTick;
this.totalTicks = totalTicks;
Expand All @@ -35,8 +35,8 @@ private ModelPartAnimationContext(
public static ModelPartAnimationContext createWithTicks(
int initialTick,
int totalTicks,
Vec3f targetVector,
Vec3f currentVector
Vec3d targetVector,
Vec3d currentVector
) {
return new ModelPartAnimationContext(
initialTick,
Expand All @@ -49,8 +49,8 @@ public static ModelPartAnimationContext createWithTicks(

public static ModelPartAnimationContext createWithProgress(
float progress,
Vec3f targetVector,
Vec3f currentVector
Vec3d targetVector,
Vec3d currentVector
) {
return new ModelPartAnimationContext(
0,
Expand All @@ -74,16 +74,16 @@ public void setProgress(float progress) {
this.progress = progress;
}

public Vec3f getCurrentVector() {
public Vec3d getCurrentVector() {
return currentVector;
}

public Vec3f getTargetVector() {
public Vec3d getTargetVector() {
return targetVector;
}

public void recalculateCurrentVector() {
this.currentVector.set(
this.currentVector = new Vec3d(
recalculateCurrentX(),
recalculateCurrentY(),
recalculateCurrentZ()
Expand All @@ -103,8 +103,8 @@ private float recalculateCurrentZ() {
}

private float calculateNewValue(
float currentValue,
float targetValue
double currentValue,
double targetValue
) {
return AnimationMath.lerp(this.progress, currentValue, targetValue);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faboslav.friendsandfoes.client.render.entity.animation;

import net.minecraft.client.model.ModelPart;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Vec3d;

public final class ModelPartAnimator
{
Expand All @@ -19,9 +19,9 @@ public static void setZPosition(ModelPart modelPart, float z) {

public static void setPosition(
ModelPart modelPart,
Vec3f position
Vec3d position
) {
modelPart.setPivot(position.getX(), position.getY(), position.getZ());
modelPart.setPivot((float) position.getX(), (float) position.getY(), (float) position.getZ());
}

public static void setXRotation(ModelPart modelPart, float x) {
Expand All @@ -38,8 +38,8 @@ public static void setZRotation(ModelPart modelPart, float z) {

public static void setRotation(
ModelPart modelPart,
Vec3f rotation
Vec3d rotation
) {
modelPart.setAngles(rotation.getX(), rotation.getY(), rotation.getZ());
modelPart.setAngles((float) rotation.getX(), (float) rotation.getY(), (float) rotation.getZ());
}
}
Loading

0 comments on commit 8be8d0e

Please sign in to comment.