Skip to content

Commit

Permalink
HEEEELP
Browse files Browse the repository at this point in the history
i dont get whats wrong with the move mixin (supposed to remove air friction)

(also idk how to rotate the textures on the agony UV so they flow towards the front face)
ice-nuclearcrackhead239 committed Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 9c7850f commit aa60756
Showing 8 changed files with 245 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
package com.nuclearcrackhead.serverboss.content.block;

import com.nuclearcrackhead.serverboss.SVBCR;
import com.nuclearcrackhead.serverboss.registry.ModDamageTypes;
import com.nuclearcrackhead.serverboss.registry.ModSounds;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import com.mojang.serialization.MapCodec;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.enums.Orientation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.state.property.Property;
import net.minecraft.text.Text;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;

import java.util.List;

import static net.minecraft.state.property.Properties.ORIENTATION;

public class Agony extends Block {
private static final EnumProperty<Orientation> ORIENTATION;
public static final MapCodec<Agony> CODEC = createCodec(Agony::new);
protected static final VoxelShape SHAPE = Block.createCuboidShape((double)1.0F, (double)0.0F, (double)1.0F, (double)16.0F, (double)15.0F, (double)16.0F);

@@ -62,4 +72,44 @@ public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity enti

super.onSteppedOn(world, pos, state, entity);
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction direction = ctx.getPlayerLookDirection().getOpposite();
Direction var10000;
switch (direction) {
case DOWN:
var10000 = ctx.getHorizontalPlayerFacing().getOpposite();
break;
case UP:
var10000 = ctx.getHorizontalPlayerFacing();
break;
case NORTH:
case SOUTH:
case WEST:
case EAST:
var10000 = Direction.UP;
break;
default:
throw new MatchException((String)null, (Throwable)null);
}

Direction direction2 = var10000;
return (BlockState)((BlockState)this.getDefaultState().with(ORIENTATION, Orientation.byDirections(direction, direction2)));
}

protected BlockState rotate(BlockState state, BlockRotation rotation) {
return (BlockState)state.with(ORIENTATION, rotation.getDirectionTransformation().mapJigsawOrientation((Orientation)state.get(ORIENTATION)));
}

protected BlockState mirror(BlockState state, BlockMirror mirror) {
return (BlockState)state.with(ORIENTATION, mirror.getDirectionTransformation().mapJigsawOrientation((Orientation)state.get(ORIENTATION)));
}

protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(new Property[]{ORIENTATION});
}

static {
ORIENTATION = Properties.ORIENTATION;
}
}
Original file line number Diff line number Diff line change
@@ -3,16 +3,29 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

public abstract class Radioactive extends FlowableFluid {

protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
Vec3d vec3d = new Vec3d((double)1.0F, (double)0.5F, (double)1.0F);
if (entity instanceof LivingEntity livingEntity) {
}

entity.slowMovement(state, vec3d);
}
/**
* @return whether the given fluid an instance of this fluid
*/
35 changes: 35 additions & 0 deletions src/main/java/com/nuclearcrackhead/serverboss/mixin/MoveMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.nuclearcrackhead.serverboss.mixin;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.data.DataTracked;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;


@Debug(export = true)
@Mixin(PlayerEntity.class)
public abstract class MoveMixin extends LivingEntity implements DataTracked {

protected MoveMixin(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
}

@Final
@Shadow private PlayerAbilities abilities;
@Inject(method = "getVelocityMultiplier()F", at = @At("RETURN"), cancellable = true)
private void injected(CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(
( !this.isOnGround() ? 1/super.getVelocityMultiplier() : super.getVelocityMultiplier() ) //LivingEntity.getVelocityMultiplier()
);
}

}
52 changes: 51 additions & 1 deletion src/main/resources/assets/svbcr/blockstates/agony.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,57 @@
{
"variants": {
"": {
"orientation=down_east": {
"model": "svbcr:block/agony",
"x": 90,
"y": 90
},
"orientation=down_north": {
"model": "svbcr:block/agony",
"x": 90
},
"orientation=down_south": {
"model": "svbcr:block/agony",
"x": 90,
"y": 180
},
"orientation=down_west": {
"model": "svbcr:block/agony",
"x": 90,
"y": 270
},
"orientation=east_up": {
"model": "svbcr:block/agony",
"y": 90
},
"orientation=north_up": {
"model": "svbcr:block/agony"
},
"orientation=south_up": {
"model": "svbcr:block/agony",
"y": 180
},
"orientation=up_east": {
"model": "svbcr:block/agony",
"x": 270,
"y": 270
},
"orientation=up_north": {
"model": "svbcr:block/agony",
"x": 270,
"y": 180
},
"orientation=up_south": {
"model": "svbcr:block/agony",
"x": 270
},
"orientation=up_west": {
"model": "svbcr:block/agony",
"x": 270,
"y": 90
},
"orientation=west_up": {
"model": "svbcr:block/agony",
"y": 270
}
}
}
89 changes: 86 additions & 3 deletions src/main/resources/assets/svbcr/models/block/agony.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,89 @@
{
"parent": "minecraft:block/cube_all",
"parent": "block/block",
"textures": {
"all": "svbcr:block/agony"
}
"bottom": "svbcr:block/agony",
"top": "svbcr:block/agony",
"north": "svbcr:block/agony_front",
"south": "svbcr:block/agony_front",
"west": "svbcr:block/agony",
"east": "svbcr:block/agony",
"particle": "#north"
},
"elements": [
{
"from": [
0,
0,
0
],
"to": [
16,
16,
16
],
"faces": {
"down": {
"uv": [
0,
0,
16,
16
],
"texture": "#bottom",
"cullface": "down"
},
"up": {
"uv": [
0,
0,
16,
16
],
"rotation": 180,
"texture": "#top",
"cullface": "up"
},
"north": {
"uv": [
0,
0,
16,
16
],
"texture": "#north",
"cullface": "north"
},
"south": {
"uv": [
0,
0,
16,
16
],
"texture": "#south",
"cullface": "south"
},
"west": {
"uv": [
0,
0,
16,
16
],
"texture": "#west",
"cullface": "west"
},
"east": {
"uv": [
0,
0,
16,
16
],
"texture": "#east",
"cullface": "east"
}
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"animation": {
"frametime": 2,
"interpolate": true
}
}
3 changes: 2 additions & 1 deletion src/main/resources/svbcr.mixins.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
"package": "com.nuclearcrackhead.serverboss.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ExampleMixin"
"ExampleMixin",
"MoveMixin"
],
"injectors": {
"defaultRequire": 1

0 comments on commit aa60756

Please sign in to comment.