<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FController</id>
	<title>BKCommonLib/Controller - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FController"/>
	<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Controller&amp;action=history"/>
	<updated>2026-04-05T12:32:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/Controller&amp;diff=7808&amp;oldid=prev</id>
		<title>RyanDo at 09:43, 12 October 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Controller&amp;diff=7808&amp;oldid=prev"/>
		<updated>2025-10-12T09:43:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:43, 12 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[BKCommonLib|« Go back]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The EntityController class contains various methods a plugin can override to alter entity behaviour.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The EntityController class contains various methods a plugin can override to alter entity behaviour.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key pulseco1_mediawiki:diff::1.12:old-1530:rev-7808 --&gt;
&lt;/table&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/Controller&amp;diff=1530&amp;oldid=prev</id>
		<title>RyanDo: Created page with &quot;« Go back  ==Introduction== The EntityController class contains various methods a plugin can override to alter entity behaviour.  ==Functionalities== * Alteri...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/Controller&amp;diff=1530&amp;oldid=prev"/>
		<updated>2021-06-09T18:15:44Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/p/BKCommonLib&quot; title=&quot;BKCommonLib&quot;&gt;« Go back&lt;/a&gt;  ==Introduction== The EntityController class contains various methods a plugin can override to alter entity behaviour.  ==Functionalities== * Alteri...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[BKCommonLib|« Go back]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The EntityController class contains various methods a plugin can override to alter entity behaviour.&lt;br /&gt;
&lt;br /&gt;
==Functionalities==&lt;br /&gt;
* Altering, cancelling or completely rewriting entity movement physics&lt;br /&gt;
* Handling block collisions, cancelling them&lt;br /&gt;
* Handling entity collisions, cancelling them&lt;br /&gt;
* Handling onTick to disable or completely alter Entity logic&lt;br /&gt;
* Handling damage dealt to the Entity&lt;br /&gt;
* Handling entity interaction (by players)&lt;br /&gt;
* Altering the name of an Entity&lt;br /&gt;
* Handling when an Entity dies&lt;br /&gt;
&lt;br /&gt;
==How to use==&lt;br /&gt;
Entity Controllers are used in combination with Common Entities. Assigning one is fairly simple: use setController. There is no need to manually bind the entity to the controller, setController takes care of that for you.&lt;br /&gt;
&lt;br /&gt;
For example, here we assign an onBlockCollision handler for items to create an explosion.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Item item = ...;&lt;br /&gt;
CommonItem entity = CommonEntity.get(item);&lt;br /&gt;
entity.setController(new EntityController&amp;lt;CommonItem&amp;gt;() {&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onBlockCollision(Block block, BlockFace hitFace) {&lt;br /&gt;
        block.getWorld().createExplosion(block.getLocation(), 5.0f);&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
});&amp;lt;/pre&amp;gt;&lt;br /&gt;
What you put in the (overridden) methods is completely up to you. You can (literally) make pigs fly.&lt;br /&gt;
&lt;br /&gt;
==Replacing all entities==&lt;br /&gt;
If you wish to replace all entities globally, so set controllers whenever a new Entity is added to the server, you can use the EntityAdd event provided by BKCommonLib:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;@EventHandler(priority = EventPriority.LOWEST)&lt;br /&gt;
public void onEntityAdd(EntityAddEvent event) {&lt;br /&gt;
    if (!(event.getEntity() instanceof Item)) {&lt;br /&gt;
        return;&lt;br /&gt;
    } &lt;br /&gt;
    CommonEntity.get((Item) event.getEntity()).setController(new CustomItemController());&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
</feed>