diff --git a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/RedstoneRotaryDistributorBlock.java b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/RedstoneRotaryDistributorBlock.java index 6bbf676..c5ff403 100644 --- a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/RedstoneRotaryDistributorBlock.java +++ b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/RedstoneRotaryDistributorBlock.java @@ -88,7 +88,7 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player return InteractionResult.PASS; } SelectorOrientation current = state.getValue(REProperties.SELECTOR_ORIENTATION); - state.setValue(REProperties.SELECTOR_ORIENTATION, current.next(state)); + state = state.setValue(REProperties.SELECTOR_ORIENTATION, current.next(state)); level.setBlock(pos, state, 3); return InteractionResult.sidedSuccess(level.isClientSide); } diff --git a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlock.java b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlock.java index a78c3d9..d094226 100644 --- a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlock.java +++ b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlock.java @@ -38,6 +38,7 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -177,6 +178,14 @@ private boolean startRotation(Level level, BlockPos motorPos, Direction directio return true; } + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return (BlockState)this.defaultBlockState() + .setValue(FACING, context.getNearestLookingDirection().getOpposite().getOpposite()) + .setValue(REProperties.SPINNING, Boolean.FALSE) + .setValue(REProperties.HAS_BEEN_ACTIVATED, Boolean.FALSE); + } + @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { diff --git a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlockEntity.java b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlockEntity.java index e4cf5b5..0c77450 100644 --- a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlockEntity.java +++ b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorBlockEntity.java @@ -121,7 +121,7 @@ public void tick(Level level, BlockPos pos, BlockState state) { this.finalTick(); } } else { - float f = this.progress + 0.5f; + float f = this.progress + ((this.goalOrientation == SelectorOrientation.LEFT) ? 0.25f : 0.5f); this.progress = f; if (this.progress >= 1.0f) { this.progress = 1.0f; diff --git a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorStructureResolver.java b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorStructureResolver.java index 1824d24..c9c1b21 100644 --- a/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorStructureResolver.java +++ b/src/main/java/io/github/codetoil/redstoneelectronics/world/level/block/servo_motor/ServoMotorStructureResolver.java @@ -44,10 +44,10 @@ public ServoMotorStructureResolver(Level level, BlockPos motorPos, Direction dir public boolean resolve() { this.toRotate.clear(); - this.finalPos = this.motorPos.relative(this.direction); // TODO Temporary + this.finalPos = this.motorPos.relative(this.direction); // TODO Temporary. Add stick rotation. BlockState state = this.level.getBlockState(this.finalPos); if (!state.hasProperty(REProperties.SELECTOR_ORIENTATION)) - { // TODO Add stick rotation. + { return false; } SelectorOrientation current = state.getValue(REProperties.SELECTOR_ORIENTATION); diff --git a/src/main/resources/assets/redstoneelectronics/blockstates/servo_motor.json b/src/main/resources/assets/redstoneelectronics/blockstates/servo_motor.json index c752335..e987a28 100644 --- a/src/main/resources/assets/redstoneelectronics/blockstates/servo_motor.json +++ b/src/main/resources/assets/redstoneelectronics/blockstates/servo_motor.json @@ -1,49 +1,95 @@ { "variants": { - "spinning=false,facing=down": { + "spinning=false,facing=down,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor", "x": 90 }, - "spinning=false,facing=east": { + "spinning=false,facing=east,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor", "y": 90 }, - "spinning=false,facing=north": { + "spinning=false,facing=north,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor" }, - "spinning=false,facing=south": { + "spinning=false,facing=south,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor", "y": 180 }, - "spinning=false,facing=up": { + "spinning=false,facing=up,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor", "x": 270 }, - "spinning=false,facing=west": { + "spinning=false,facing=west,has_been_activated=false": { "model": "redstoneelectronics:block/servo_motor", "y": 270 }, - "spinning=true,facing=down": { - "model": "redstoneelectronics:block/servo_motor_spinning", + "spinning=true,facing=down,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor", + "x": 90 + }, + "spinning=true,facing=east,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor", + "y": 90 + }, + "spinning=true,facing=north,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor" + }, + "spinning=true,facing=south,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor", + "y": 180 + }, + "spinning=true,facing=up,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor", + "x": 270 + }, + "spinning=true,facing=west,has_been_activated=false": { + "model": "redstoneelectronics:block/servo_motor", + "y": 270 + }, + "spinning=false,facing=down,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", + "x": 90 + }, + "spinning=false,facing=east,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", + "y": 90 + }, + "spinning=false,facing=north,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor" + }, + "spinning=false,facing=south,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", + "y": 180 + }, + "spinning=false,facing=up,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", + "x": 270 + }, + "spinning=false,facing=west,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", + "y": 270 + }, + "spinning=true,facing=down,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", "x": 90 }, - "spinning=true,facing=east": { - "model": "redstoneelectronics:block/servo_motor_spinning", + "spinning=true,facing=east,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", "y": 90 }, - "spinning=true,facing=north": { - "model": "redstoneelectronics:block/servo_motor_spinning" + "spinning=true,facing=north,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor" }, - "spinning=true,facing=south": { - "model": "redstoneelectronics:block/servo_motor_spinning", + "spinning=true,facing=south,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", "y": 180 }, - "spinning=true,facing=up": { - "model": "redstoneelectronics:block/servo_motor_spinning", + "spinning=true,facing=up,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", "x": 270 }, - "spinning=true,facing=west": { - "model": "redstoneelectronics:block/servo_motor_spinning", + "spinning=true,facing=west,has_been_activated=true": { + "model": "redstoneelectronics:block/servo_motor", "y": 270 } } diff --git a/src/main/resources/assets/redstoneelectronics/models/block/servo_motor.json b/src/main/resources/assets/redstoneelectronics/models/block/servo_motor.json index 6546976..ff79aeb 100644 --- a/src/main/resources/assets/redstoneelectronics/models/block/servo_motor.json +++ b/src/main/resources/assets/redstoneelectronics/models/block/servo_motor.json @@ -1,17 +1,21 @@ { "credit": "Made with Blockbench", + "textures": { + "0": "minecraft:block/dispenser_front_vertical", + "1": "minecraft:block/furnace_top", + "particle": "minecraft:block/furnace_top" + }, "elements": [ { "from": [0, 0, 0], "to": [16, 16, 16], - "color": 8, "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "east": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "west": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#missing"} + "north": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "east": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "west": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#1"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#1"} } } ] diff --git a/src/main/resources/assets/redstoneelectronics/models/block/servo_motor_spinning.json b/src/main/resources/assets/redstoneelectronics/models/block/servo_motor_spinning.json deleted file mode 100644 index 6546976..0000000 --- a/src/main/resources/assets/redstoneelectronics/models/block/servo_motor_spinning.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "credit": "Made with Blockbench", - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "color": 8, - "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "east": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "west": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#missing"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#missing"} - } - } - ] -} \ No newline at end of file