Skip to content

Commit

Permalink
update to 1.20.5 and fix #24 and #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchanted-Games committed Apr 18, 2024
1 parent 4587121 commit ddf03b0
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 137 deletions.
41 changes: 28 additions & 13 deletions build.gradle
@@ -1,15 +1,15 @@
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
Expand All @@ -18,6 +18,18 @@ repositories {
// for more information about repositories.
}

loom {
splitEnvironmentSourceSets()

mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -26,6 +38,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

}

processResources {
Expand All @@ -36,28 +49,30 @@ processResources {
}
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
from components.java
}
}
Expand All @@ -69,4 +84,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
16 changes: 9 additions & 7 deletions gradle.properties
Expand Up @@ -2,14 +2,16 @@
org.gradle.jvmargs=-Xmx3G

# Mod Properties
mod_version = 1.9.2
maven_group = games.enchanted.vertical-slabs
archives_base_name = enchanted-vertical-slabs
mod_version = 1.9.2
maven_group = games.enchanted.vertical-slabs
archives_base_name = enchanted-vertical-slabs

# Dependencies
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1
minecraft_version=1.20.5-rc1
yarn_mappings=1.20.5-rc1+build.1
loader_version=0.15.10

#Fabric api
fabric_version=0.91.2+1.20.4
fabric_version=0.97.3+1.20.5

org.gradle.java.home=D:/win/Program Files/Eclipse Adoptium/jdk-21.0.1.12-hotspot
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions remappedSrc/games/enchanted/mixins/WallBlockMixin.java
Expand Up @@ -21,7 +21,7 @@
import games.enchanted.registry.types.CombinableVerticalSlabBlock;

@Mixin(WallBlock.class)
public abstract class WallBlockMixin {
public abstract class WallBlockMixin<R> {
@Shadow
abstract public BlockState getStateWith(BlockState state, boolean north, boolean east, boolean south, boolean west,
VoxelShape aboveShape);
Expand Down Expand Up @@ -74,7 +74,7 @@ private WallShape isConnectedUseShape(boolean connected, BlockState blockState)
@Inject(at = @At("TAIL"), cancellable = true, method = "Lnet/minecraft/block/WallBlock;getStateWith(Lnet/minecraft/world/WorldView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;ZZZZ)Lnet/minecraft/block/BlockState;")
private BlockState getStateWith(WorldView world, BlockState state, BlockPos pos, BlockState aboveState,
boolean north, boolean east, boolean south, boolean west,
CallbackInfoReturnable infor) {
CallbackInfoReturnable<R> infor) {

VoxelShape voxelShape = aboveState.getCollisionShape(world, pos).getFace(Direction.DOWN);
BlockState blockState = this.getStateWith(state, north, east, south, west, voxelShape);
Expand Down
2 changes: 1 addition & 1 deletion remappedSrc/games/enchanted/registry/ModItems.java
Expand Up @@ -11,7 +11,7 @@

public class ModItems {
// block items

// coppers
public static final BlockItem VERTICAL_CUT_COPPER_SLAB = registerBlockItem(ModBlocks.VERTICAL_CUT_COPPER_SLAB,
"vertical_cut_copper_slab");
Expand Down
@@ -1,9 +1,10 @@
package games.enchanted.registry.types;

import com.mojang.serialization.MapCodec;

import net.minecraft.block.*;
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
Expand Down Expand Up @@ -174,15 +175,6 @@ public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState stat
}
return false;
}

@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
if (state.get(SINGLE) != false) {
return Waterloggable.super.canFillWithFluid(world, pos, state, fluid);
}
return false;
}

@Override
public FluidState getFluidState(BlockState state) {
if (state.get(Properties.WATERLOGGED).booleanValue()) {
Expand All @@ -192,4 +184,10 @@ public FluidState getFluidState(BlockState state) {
return state.getFluidState();
}

@Override
protected MapCodec<? extends CombinableVerticalSlabBlock> getCodec() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getCodec'");
}

}
Expand Up @@ -5,7 +5,7 @@

public class VerticalSlabItem extends BlockItem{

public VerticalSlabItem(Block block, Settings settings) {
public VerticalSlabItem(Block block, net.minecraft.item.Item.Settings settings) {
super(block, settings);
}

Expand Down
Expand Up @@ -3,8 +3,6 @@
import com.mojang.serialization.MapCodec;

import net.minecraft.block.*;
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
Expand All @@ -14,9 +12,6 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
Expand All @@ -39,9 +34,9 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> stateMan
public CombinableVerticalSlabBlock(Settings settings, SoundEvent blockSoundEvent) {
super(settings);

setDefaultState(this.stateManager.getDefaultState().with(SINGLE, true));
setDefaultState(this.stateManager.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
this.setDefaultState((BlockState) ((BlockState) this.getDefaultState().with(Properties.WATERLOGGED, false)));
setDefaultState(stateManager.getDefaultState().with(SINGLE, true));
setDefaultState(stateManager.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
setDefaultState(stateManager.getDefaultState().with(Properties.WATERLOGGED, false));

blockPlaceSound = blockSoundEvent;
}
Expand Down Expand Up @@ -77,94 +72,36 @@ public boolean hasSidedTransparency(BlockState state) {
return true;
}

@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos,
PlayerEntity player, Hand hand,
BlockHitResult hit) {

ActionResult ACTION;

ACTION = combineSlab(state, world, pos, player, hand, hit);

return ACTION;
}

private ActionResult combineSlab(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {

player.getStackInHand(hand);
// checks if player clicked on block with same item type
if (player.getAbilities().allowModifyWorld
&& ItemStack.areEqual(new ItemStack(this), player.getStackInHand(hand))
&& state.get(SINGLE)) {

ActionResult RESULT = ActionResult.FAIL;
player.getBlockX();

if (state.get(SINGLE)) {
Direction HITSIDE = hit.getSide();

// is facing north and hit from south
if (state.get(FACING) == Direction.NORTH) {
if (HITSIDE == Direction.SOUTH) {
world.setBlockState(pos, state.with(SINGLE, false));
RESULT = sucessfulPlace(player, hand, world, pos);
}
}
// is facing east and hit from west
else if (state.get(FACING) == Direction.EAST) {
if (HITSIDE == Direction.WEST) {
world.setBlockState(pos, state.with(SINGLE, false));
RESULT = sucessfulPlace(player, hand, world, pos);
}
}
// is facing south and hit from north
else if (state.get(FACING) == Direction.SOUTH) {
if (HITSIDE == Direction.NORTH) {
world.setBlockState(pos, state.with(SINGLE, false));
RESULT = sucessfulPlace(player, hand, world, pos);
}
}
// is facing west and hit from east
else if (state.get(FACING) == Direction.WEST) {
if (HITSIDE == Direction.EAST) {
world.setBlockState(pos, state.with(SINGLE, false));
RESULT = sucessfulPlace(player, hand, world, pos);
}
}

else {

}

}

return RESULT;
} else {
return ActionResult.PASS;
protected boolean canReplace(BlockState state, ItemPlacementContext context) {
ItemStack itemStack = context.getStack();
if (!state.get(SINGLE) && !(itemStack.isOf(this.asItem()))) {
return false;
}

}

private ActionResult sucessfulPlace(PlayerEntity player, Hand hand, World world, BlockPos pos) {
// checks if player is in creative and removes 1 item if not
boolean isInCreative = player.getAbilities().creativeMode;
if (!isInCreative) {
player.getStackInHand(hand).setCount(player.getStackInHand(hand).getCount() - 1);
double hitposX = context.getHitPos().x - (double)context.getBlockPos().getX();
double hitposZ = context.getHitPos().z - (double)context.getBlockPos().getZ();

Direction facingDirection = state.get(Properties.HORIZONTAL_FACING);
switch (facingDirection.toString()) {
case "north":
return hitposZ >= 0.5;
case "east":
return hitposX <= 0.5;
case "south":
return hitposZ <= 0.5;
case "west":
return hitposX >= 0.5;
default:
return false;
}
playPlaceSound(world, pos);

// makes arm swing
return ActionResult.success(world.isClient);
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState = ctx.getWorld().getBlockState(ctx.getBlockPos());
if (blockState.isOf(this)) {
return blockState.with(SINGLE, false).with(Properties.WATERLOGGED, false);
}
return this.getDefaultState().with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing());
}

Expand Down
Expand Up @@ -6,30 +6,30 @@
"uvlock": true
},
"facing=north,single_slab=false": {
"model": "minecraft:block/cut_copper"
"model": "minecraft:block/exposed_cut_copper"
},
"facing=east,single_slab=true": {
"model": "enchanted-vertical-slabs:block/vertical_waxed_exposed_cut_copper_slab",
"y": 270,
"uvlock": true
},
"facing=east,single_slab=false": {
"model": "minecraft:block/cut_copper"
"model": "minecraft:block/exposed_cut_copper"
},
"facing=south,single_slab=true": {
"model": "enchanted-vertical-slabs:block/vertical_waxed_exposed_cut_copper_slab",
"uvlock": true
},
"facing=south,single_slab=false": {
"model": "minecraft:block/cut_copper"
"model": "minecraft:block/exposed_cut_copper"
},
"facing=west,single_slab=true": {
"model": "enchanted-vertical-slabs:block/vertical_waxed_exposed_cut_copper_slab",
"y": 90,
"uvlock": true
},
"facing=west,single_slab=false": {
"model": "minecraft:block/cut_copper"
"model": "minecraft:block/exposed_cut_copper"
}
}
}

0 comments on commit ddf03b0

Please sign in to comment.