Skip to content

Latest commit

 

History

History
99 lines (88 loc) · 2.88 KB

API.md

File metadata and controls

99 lines (88 loc) · 2.88 KB

License Version jitpack

Implementation

Gradle

repositories {
	maven { url 'https://jitpack.io' }
}

dependencies {
        implementation 'com.github.max1mde:FancyPhysics:2.6.1'
}

Maven

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

<dependency>
    <groupId>com.github.max1mde</groupId>
    <artifactId>FancyPhysics</artifactId>
    <version>2.6.1</version>
</dependency>

Examples


FancyPhysics instance

API fancyPhysicsAPI = FancyPhysics.getAPI();

Particles

fancyPhysicsAPI.getParticleGenerator().simulateBlockParticles(location, material);
fancyPhysicsAPI.getParticleGenerator().simulateBloodParticles(location, material);
fancyPhysicsAPI.getParticleGenerator().simulateSplashBloodParticles(location, material);

Config

if(fancyPhysicsAPI.getConfig().isRealisticExplosion()) {
	// Do something
}

Particle list

// For example remove all currently existing particles
for(BlockDisplay blockDisplay : fancyPhysicsAPI.getBlockDisplayList()) {
	blockDisplay.remove();
}
fancyPhysicsAPI.getBlockDisplayList().clear();

Events

ParticleSpawnEvent

    @EventHandler
    public void onParticleSpawnEvent(ParticleSpawnEvent event) {
        // Changes the particle texture to a diamond block
        BlockDisplay display = event.getParticleDisplay();
        display.setBlock(Material.DIAMOND_BLOCK.createBlockData());
    }

ParticleEffectEvent

    @EventHandler
    public void onParticleEffect(ParticleEffectEvent event) {
        // Do something with the list
        List<BlockDisplay> displayList = event.getParticleDisplayList();

        if(event.getLocation().getWorld().getName().equals("your_custom_world")) {
            // You can cancel every fancy physics event
            event.setCancelled(true);
        }
    }

TreeBreakEvent

    @EventHandler
    public void onTreeBreak(TreeBreakEvent event) {
        // Cancel the normal animation
        event.setCancelled(true);
        Tree tree = event.getTree();
        
        // Play the instant break animation instead of the falling down animation
        tree.breakInstantWithParticles();
    }