Chorus models & fixes

This commit is contained in:
paulevsGitch 2020-10-15 14:18:28 +03:00
parent 9731063f95
commit 53ad813110
13 changed files with 513 additions and 210 deletions

View file

@ -1,18 +1,34 @@
package ru.betterend.mixin.common; package ru.betterend.mixin.common;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.ChorusFlowerBlock; import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.util.BlocksHelper;
@Mixin(ChorusFlowerBlock.class) @Mixin(ChorusFlowerBlock.class)
public class ChorusFlowerBlockMixin { public class ChorusFlowerBlockMixin {
@Shadow
@Final
private ChorusPlantBlock plantBlock;
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) { private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) { if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) {
@ -20,4 +36,28 @@ public class ChorusFlowerBlockMixin {
info.cancel(); info.cancel();
} }
} }
@Inject(method = "randomTick", at = @At("HEAD"), cancellable = true)
private void onTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) {
if (world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) {
BlockPos up = pos.up();
if (world.isAir(up) && up.getY() < 256) {
int i = state.get(ChorusFlowerBlock.AGE);
if (i < 5) {
this.grow(world, up, i + 1);
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true));
info.cancel();
}
}
}
}
@Shadow
private static boolean isSurroundedByAir(WorldView world, BlockPos pos, @Nullable Direction exceptDirection) { return false; }
@Shadow
private void grow(World world, BlockPos pos, int age) {}
@Shadow
private void die(World world, BlockPos pos) {}
} }

View file

@ -18,14 +18,13 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry; import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.util.BlocksHelper;
@Mixin(ChorusPlantBlock.class) @Mixin(ChorusPlantBlock.class)
public class ChorusPlantBlockMixin { public class ChorusPlantBlockMixin {
private static final BooleanProperty ROOTS = BooleanProperty.of("roots");
@Inject(method = "appendProperties", at = @At("TAIL")) @Inject(method = "appendProperties", at = @At("TAIL"))
private void addProperties(StateManager.Builder<Block, BlockState> builder, CallbackInfo info) { private void addProperties(StateManager.Builder<Block, BlockState> builder, CallbackInfo info) {
builder.add(ROOTS); builder.add(BlocksHelper.ROOTS);
} }
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
@ -41,10 +40,10 @@ public class ChorusPlantBlockMixin {
BlockState plant = info.getReturnValue(); BlockState plant = info.getReturnValue();
if (plant.isOf(Blocks.CHORUS_PLANT)) { if (plant.isOf(Blocks.CHORUS_PLANT)) {
if (!plant.get(Properties.DOWN) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { if (!plant.get(Properties.DOWN) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) {
info.setReturnValue(plant.with(Properties.DOWN, true).with(ROOTS, true)); info.setReturnValue(plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true));
} }
else { else {
info.setReturnValue(plant.with(ROOTS, false)); info.setReturnValue(plant.with(BlocksHelper.ROOTS, false));
} }
} }
} }

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.FallingBlock; import net.minecraft.block.FallingBlock;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.tag.BlockTags; import net.minecraft.tag.BlockTags;
import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockMirror;
@ -23,6 +24,8 @@ import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.registry.BlockTagRegistry; import ru.betterend.registry.BlockTagRegistry;
public class BlocksHelper { public class BlocksHelper {
public static final BooleanProperty ROOTS = BooleanProperty.of("roots");
public static final int FLAG_UPDATE_BLOCK = 1; public static final int FLAG_UPDATE_BLOCK = 1;
public static final int FLAG_SEND_CLIENT_CHANGES = 2; public static final int FLAG_SEND_CLIENT_CHANGES = 2;
public static final int FLAG_NO_RERENDER = 4; public static final int FLAG_NO_RERENDER = 4;

View file

@ -0,0 +1,50 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/chorus_plant_flower_side",
"side": "betterend:block/chorus_plant_flower_side",
"top": "betterend:block/chorus_plant_flower_top",
"bottom": "betterend:block/chorus_plant_flower_bottom"
},
"elements": [
{
"__comment": "Box1",
"from": [ 0, 2, 2 ],
"to": [ 16, 14, 14 ],
"faces": {
"down": { "uv": [ 0, 2, 16, 14 ], "texture": "#bottom" },
"up": { "uv": [ 0, 2, 16, 14 ], "texture": "#top" },
"north": { "uv": [ 0, 2, 16, 14 ], "texture": "#side" },
"south": { "uv": [ 0, 2, 16, 14 ], "texture": "#side" },
"west": { "uv": [ 2, 2, 14, 14 ], "texture": "#side" },
"east": { "uv": [ 2, 2, 14, 14 ], "texture": "#side" }
}
},
{
"__comment": "Box1",
"from": [ 2, 2, 0 ],
"to": [ 14, 14, 16 ],
"faces": {
"down": { "uv": [ 2, 0, 14, 16 ], "texture": "#bottom" },
"up": { "uv": [ 2, 0, 14, 16 ], "texture": "#top" },
"north": { "uv": [ 2, 2, 14, 14 ], "texture": "#side" },
"south": { "uv": [ 2, 2, 14, 14 ], "texture": "#side" },
"west": { "uv": [ 0, 2, 16, 14 ], "texture": "#side" },
"east": { "uv": [ 0, 2, 16, 14 ], "texture": "#side" }
}
},
{
"__comment": "Box1",
"from": [ 2, 0, 2 ],
"to": [ 14, 16, 14 ],
"faces": {
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#bottom" },
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
"east": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }
}
}
]
}

View file

@ -0,0 +1,175 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/chorus_plant_flower_petal",
"texture": "betterend:block/chorus_plant_flower_petal",
"center": "betterend:block/chorus_plant_flower_center",
"texture1": "betterend:block/chorus_plant_flower_fur"
},
"elements": [
{
"__comment": "Box1",
"from": [ 4, 0, 4 ],
"to": [ 12, 2, 12 ],
"faces": {
"down": { "uv": [ 0, 8, 8, 16 ], "texture": "#center" },
"up": { "uv": [ 0, 0, 8, 8 ], "texture": "#center" },
"north": { "uv": [ 8, 14, 16, 16 ], "texture": "#center" },
"south": { "uv": [ 8, 14, 16, 16 ], "texture": "#center" },
"west": { "uv": [ 8, 14, 16, 16 ], "texture": "#center" },
"east": { "uv": [ 8, 14, 16, 16 ], "texture": "#center" }
}
},
{
"__comment": "PlaneY2",
"from": [ 4.5, 1.125, 16 ],
"to": [ 20.5, 1.126, 32 ],
"rotation": { "origin": [ 4.5, 1.125, 16 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }
}
},
{
"__comment": "PlaneY2",
"from": [ 0, 1.25, 4.5 ],
"to": [ 16, 1.251, 20.5 ],
"rotation": { "origin": [ 0, 1.25, 4.5 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }
}
},
{
"__comment": "PlaneY2",
"from": [ -4.5, 1.375, -16 ],
"to": [ 11.5, 1.376, 0 ],
"rotation": { "origin": [ 11.5, 1.375, 0 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneY2",
"from": [ 0, 1, -4.5 ],
"to": [ 16, 1.001, 11.5 ],
"rotation": { "origin": [ 16, 1, 11.5 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX6",
"from": [ 11, 0.999, 0.5 ],
"to": [ 20, 0.9999999, 16.5 ],
"rotation": { "origin": [ 11, 1, 0.5 ], "axis": "z", "angle": 22.5 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 7, 16, 16 ], "texture": "#texture", "rotation": 90 },
"up": { "uv": [ 16, 16, 0, 7 ], "texture": "#texture", "rotation": 270 }
}
},
{
"__comment": "PlaneX6",
"from": [ 19.25, 4.374, 0.5 ],
"to": [ 28.25, 4.375, 16.5 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 9 ], "texture": "#texture", "rotation": 90 },
"up": { "uv": [ 16, 9, 0, 0 ], "texture": "#texture", "rotation": 270 }
}
},
{
"__comment": "PlaneY11",
"from": [ -3, 0.999, 0 ],
"to": [ 5, 0.9999999, 16 ],
"rotation": { "origin": [ 5, 1, 0 ], "axis": "z", "angle": -22.5 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 8, 16, 16 ], "texture": "#texture", "rotation": 270 },
"up": { "uv": [ 0, 8, 16, 16 ], "texture": "#texture", "rotation": 270 }
}
},
{
"__comment": "PlaneY11",
"from": [ -10.375, 3.999, 0 ],
"to": [ -2.375, 4, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 8 ], "texture": "#texture", "rotation": 270 },
"up": { "uv": [ 0, 0, 16, 8 ], "texture": "#texture", "rotation": 270 }
}
},
{
"__comment": "PlaneY13",
"from": [ -0.5, 1, 11 ],
"to": [ 15.5, 1.001, 20 ],
"rotation": { "origin": [ -0.5, 1, 11 ], "axis": "x", "angle": -22.5 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 7, 16, 16 ], "texture": "#texture" },
"up": { "uv": [ 0, 7, 16, 16 ], "texture": "#texture", "rotation": 180 }
}
},
{
"__comment": "PlaneY13",
"from": [ -0.5, 4.5, 19.25 ],
"to": [ 15.5, 4.501, 28.25 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 9 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 16, 9 ], "texture": "#texture", "rotation": 180 }
}
},
{
"__comment": "PlaneY18",
"from": [ 1, 0.999, -4 ],
"to": [ 17, 0.9999999, 5 ],
"rotation": { "origin": [ 1, 1, 5 ], "axis": "x", "angle": 22.5 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 8, 16, 16 ], "texture": "#texture", "rotation": 180 },
"up": { "uv": [ 0, 8, 16, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneY18",
"from": [ 1, 4.374, -12.25 ],
"to": [ 17, 4.375, -3.25 ],
"rotation": { "origin": [ 1, 4.375, -3.25 ], "axis": "x", "angle": 0 },
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 8 ], "texture": "#texture", "rotation": 180 },
"up": { "uv": [ 0, 0, 16, 8 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX20",
"from": [ 2, 1, 2 ],
"to": [ 2.001, 8, 18 ],
"rotation": { "origin": [ 2, 1, 2 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 9, 16, 16 ], "texture": "#texture1" },
"east": { "uv": [ 0, 9, 16, 16 ], "texture": "#texture1" }
}
},
{
"__comment": "PlaneX20",
"from": [ 14, 1, 2 ],
"to": [ 14.001, 8, 18 ],
"rotation": { "origin": [ 14, 1, 2 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 9, 16, 16 ], "texture": "#texture1" },
"east": { "uv": [ 0, 9, 16, 16 ], "texture": "#texture1" }
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,22 @@
{
"variants": {
"age=0": {
"model": "betterend:block/chorus_plant_flower"
},
"age=1": {
"model": "betterend:block/chorus_plant_flower"
},
"age=2": {
"model": "betterend:block/chorus_plant_flower"
},
"age=3": {
"model": "betterend:block/chorus_plant_flower"
},
"age=4": {
"model": "betterend:block/chorus_plant_flower"
},
"age=5": {
"model": "betterend:block/chorus_plant_flower_open"
}
}
}

View file

@ -0,0 +1,14 @@
{
"defaultMap": {
"spriteMap": [
{
"sprite": "betterend:block/chorus_plant_flower_petal",
"material": "betterend:waving_floor"
},
{
"sprite": "betterend:block/chorus_plant_flower_fur",
"material": "betterend:waving_floor"
}
]
}
}