Repository navigation
[DRAFT] Misc. Tutorial & Notes
Prathamesh Sahasrabhojane edited this page Mar 26, 2020
·
1 revision
These tutorials/notes are for the IntelliJ IDE. They don't have to apply on other IDEs.
Please let me know if anything here is incorrect or if there is a better way in doing something.
I just started yesterday and I am just trying to give some advice so that others won't waste as much time as I did in dealing with these problems.
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- private static final Logger logger = LoggerFactory.getLogger(yourSystemName.class); // inside your class
- logger.info("The message you want to print");
This code was extracted from the DamagingBlocks module
@RegisterSystem(RegisterMode.AUTHORITY)
public class yourSystemName extends BaseComponentSystem implements UpdateSubscriberSystem {
private static final Logger logger = LoggerFactory.getLogger(speedBoosterSystem.class);
@In
private BlockEntityRegistry blockEntityProvider;
@In
private EntityManager entityManager;
@In
private WorldProvider worldProvider;
@Override
public void update(float delta) {
// This foreach loop gets the player
for (EntityRef entity : entityManager.getEntitiesWith(CharacterMovementComponent.class, LocationComponent.class)) {
LocationComponent loc = entity.getComponent(LocationComponent.class); // Location component of player
Vector3f pos = loc.getWorldPosition(); // Position of player
pos.setY( pos.getY() -1 ); // Decrease Y-axis by one to get position under player
Block block = worldProvider.getBlock(pos); // Get the block under the player
logger.info( block.getDisplayName() ); // Print to the game console the name of the block
}
}
}
If you are using IntelliJ and your imports are disappearing once you add them, or at random. This is because IntelliJ only leaves the imports your code is using/accessing. In case this happens to you, do one of the following :
- Go to File->Settings->Editor->General->Auto Import and make sure "Optimize imports on the fly" is set to false.
- Write the code first and press Alt+Enter on the unimported class to automatically import them.
Found a problem on this page? Fix it! Don't wanna? Report it!
- What is Terasology
- Why Terasology
- Project Overview
- Setup a headless server
- Troubleshooting for Players
- Quick Start
- Prepare Workspace (Full)
- Prepare Workspace (Light)
- Develop Modules
- Deal with Forks
- Depend on Modules
- Using IRC
- Troubleshooting for Developers
- Art
- Code
- Architecture
- Conventions
- Structure
- Versioning
- How to make interactive blocks
- Developing Commands
- Modding API
- IO API for Modules
- Translation
- Record & Replay