Fix conveyor belts

This commit is contained in:
Stone_Red
2022-05-13 10:21:59 +02:00
parent a4ef1e9ae4
commit b7caf1ce35
2 changed files with 11 additions and 18 deletions
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
@@ -2,14 +2,14 @@ package com.yes.yes.behaviours;
import com.yes.yes.utils.*; import com.yes.yes.utils.*;
public class RecieveBehaviour extends Component { public class ReceiveBehaviour extends Component {
private Coordinate direction; private final Coordinate direction;
private String dataKey; private final String dataKey;
private Entity offerer; private Entity offerer;
public RecieveBehaviour(Entity entity, BlockContainer blockContainer, Coordinate direction, String dataKey) { public ReceiveBehaviour(Entity entity, BlockContainer blockContainer, Coordinate direction, String dataKey) {
super(entity, blockContainer); super(entity, blockContainer);
this.direction = direction; this.direction = direction;
this.dataKey = dataKey; this.dataKey = dataKey;
@@ -17,7 +17,6 @@ public class RecieveBehaviour extends Component {
private void placed(Entity entity) { private void placed(Entity entity) {
System.out.println("Entity placed in range");
try { try {
if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) {
this.offerer = entity; this.offerer = entity;
@@ -41,11 +40,15 @@ public class RecieveBehaviour extends Component {
void receive(Item item) { void receive(Item item) {
if (offerer == null) return; if (offerer == null) return;
if (this.parent.getData(dataKey) == item)
this.offerer.trigger("itemAccepted", this.parent);
if (this.parent.getData(dataKey) != null) return; if (this.parent.getData(dataKey) != null) return;
this.parent.setData(dataKey, item); this.parent.setData(dataKey, item);
this.parent.trigger(dataKey + "Changed", item); this.parent.trigger(dataKey + "Changed", item);
this.offerer.trigger("itemAccepted", this.parent);
} }
@Override @Override