mirror of
https://github.com/dragonruler1000/hdm-mod.git
synced 2025-06-29 08:29:33 -05:00
Merge pull request #17 from dragonruler1000/DEV
Add credits field and fix portal block activation logic
This commit is contained in:
commit
bcf7cbd7d1
4 changed files with 27 additions and 22 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Block> 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
|
||||
|
|
|
@ -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<Block, BlockState> builder) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue