diff --git a/build.gradle b/build.gradle index c1e84cb..c1bd60a 100644 --- a/build.gradle +++ b/build.gradle @@ -141,7 +141,7 @@ tasks.named('processResources', ProcessResources).configure { forge_version : forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, - mod_authors : mod_authors, mod_description: mod_description,] + mod_authors : mod_authors, credits: credits, mod_description: mod_description,] inputs.properties replaceProperties diff --git a/gradle.properties b/gradle.properties index e02d200..fc1c5f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,5 +45,6 @@ mod_version=1.2 mod_group_id=us.minecraftchest2 # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. mod_authors=Minecraftchest2 +credits=Everyone on the Tardis Mod Discord and on the hackclub slack that helped me debug my mod. # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. mod_description=A Mod Inspired by "His Dark Materials" By Philip Pullman diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java index b11579b..5c7d76f 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/ModBlocks.java @@ -11,6 +11,7 @@ import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import us.minecraftchest2.hdm_mod.Hdm_mod; +import us.minecraftchest2.hdm_mod.block.custom.Window; import us.minecraftchest2.hdm_mod.item.ModItems; import us.minecraftchest2.hdm_mod.item.ModItemGroup; @@ -40,7 +41,7 @@ public class ModBlocks { // Registering a "portal" block called "window" with different properties public static final RegistryObject PORTAL_BLOCK = registerBlock("window", - () -> new Block( + () -> new Window( AbstractBlock.Properties.create(Material.PORTAL) // Base material is portal .doesNotBlockMovement() // Entities can move through this block .harvestLevel(10) // High harvest level diff --git a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java index e043c36..c811185 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/block/custom/Window.java @@ -98,36 +98,39 @@ public class Window extends HorizontalBlock { * @param hit Hit result information * @return Result of the interaction */ + @SuppressWarnings("deprecation") @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, - PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - String message = "blockActivated"; - ITextComponent msg = new StringTextComponent(message); - player.sendMessage(msg, player.getUniqueID()); + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - // Client-side: Only show a status message if (worldIn.isRemote()) { player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true); return ActionResultType.SUCCESS; } - // Server-side logic below - player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID()); + if (!worldIn.isRemote()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + if (player.isCrouching()) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); - // Prevent action if sneaking (crouching) - if (player.isCrouching()) { - return ActionResultType.PASS; - } + if (worldIn.getServer() == null) return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); MinecraftServer server = worldIn.getServer(); - if (server == null) { - return ActionResultType.FAIL; + if (worldIn.getDimensionKey() == ModDimensions.World1) { + ServerWorld overWorld = server.getWorld(World.OVERWORLD); + if (overWorld != null) { + player.changeDimension(overWorld, new SimpleTeleporter(pos, false)); + } } - + ServerWorld targetWorld; boolean goingToCustom = worldIn.getDimensionKey() != ModDimensions.World1; - ServerWorld targetWorld = goingToCustom - ? server.getWorld(ModDimensions.World1) - : server.getWorld(World.OVERWORLD); + + if (goingToCustom) { + targetWorld = server.getWorld(ModDimensions.World1); + } else { + ServerWorld world1 = server.getWorld(ModDimensions.World1); + if (world1 != null) { + player.changeDimension(world1, new SimpleTeleporter(pos, true)); + } + targetWorld = server.getWorld(World.OVERWORLD); + } if (targetWorld != null) { SimpleTeleporter teleporter = new SimpleTeleporter(pos, goingToCustom); @@ -142,7 +145,7 @@ public class Window extends HorizontalBlock { return ActionResultType.SUCCESS; } - return ActionResultType.FAIL; + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } @@ -166,7 +169,7 @@ public class Window extends HorizontalBlock { } /** - * Adds the horizontal facing property to the block's state container + * Adds the horizontal-facing property to the block's state container */ @Override protected void fillStateContainer(StateContainer.Builder builder) {