mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-04 00:46:01 +02:00
Fix conveyor belts
This commit is contained in:
Generated
-10
@@ -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>
|
|
||||||
+9
-6
@@ -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
|
||||||
Reference in New Issue
Block a user