Skip to content

Commit aef304d

Browse files
committed
Fix some gradle things, add teleport handling
1 parent ba7a679 commit aef304d

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ dependencies {
174174

175175
// Example for how to get properties into the manifest for reading by the runtime..
176176
jar {
177-
destinationDir = file("$rootDir/build-out")
177+
destinationDirectory = file("$rootDir/build-out")
178178
finalizedBy('reobfJar')
179179
manifest {
180180
attributes([
181181
"Specification-Title" : "compactmachines",
182182
"Specification-Vendor" : "",
183183
"Specification-Version" : "1", // We are version 1 of ourselves
184184
"Implementation-Title" : project.name,
185-
"Implementation-Version" : "${version}",
185+
"Implementation-Version" : "${archiveVersion}",
186186
"Implementation-Vendor" : "",
187187
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
188188
])
@@ -194,8 +194,8 @@ task apiJar(type: Jar) {
194194
from(sourceSets.main.allJava)
195195
from(sourceSets.main.output)
196196
include 'com/robotgryphon/compactmachines/api/**'
197-
classifier = 'api'
198-
destinationDir = file("$rootDir/build-out")
197+
archiveClassifier = 'api'
198+
destinationDirectory = file("$rootDir/build-out")
199199
}
200200

201201
artifacts {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55

66
minecraft_version=1.16.5
7-
forge_version=36.0.46
7+
forge_version=36.1.4
88
mappings_version=1.16.5
99

1010
mod_id=compactmachines
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.robotgryphon.compactmachines.teleportation;
2+
3+
import com.robotgryphon.compactmachines.CompactMachines;
4+
import com.robotgryphon.compactmachines.core.Registration;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.entity.player.ServerPlayerEntity;
7+
import net.minecraft.nbt.CompoundNBT;
8+
import net.minecraft.nbt.NBTUtil;
9+
import net.minecraft.util.math.vector.Vector3d;
10+
import net.minecraftforge.event.entity.living.EntityTeleportEvent;
11+
import net.minecraftforge.eventbus.api.SubscribeEvent;
12+
import net.minecraftforge.fml.common.Mod;
13+
14+
@Mod.EventBusSubscriber(modid = CompactMachines.MOD_ID)
15+
public class TeleportationEventHandler {
16+
17+
@SubscribeEvent
18+
public static void onEntityTeleport(final EntityTeleportEvent evt) {
19+
// Allow teleport commands, we don't want to trap people anywhere
20+
if(evt instanceof EntityTeleportEvent.TeleportCommand)
21+
return;
22+
23+
// Allow ender pearls as well, since players can teleport around inside machines
24+
if(evt instanceof EntityTeleportEvent.EnderPearl)
25+
return;
26+
27+
// Make sure we only target player entities on a server
28+
Entity entity = evt.getEntity();
29+
if (entity instanceof ServerPlayerEntity) {
30+
ServerPlayerEntity sp = (ServerPlayerEntity) entity;
31+
if(sp.level.dimension() == Registration.COMPACT_DIMENSION) {
32+
if(evt.isCancelable()) {
33+
evt.setCanceled(true);
34+
return;
35+
}
36+
37+
// If the event isn't cancelable, force the position to
38+
// be the same as the starting point
39+
Vector3d prev = evt.getPrev();
40+
evt.setTargetX(prev.x);
41+
evt.setTargetY(prev.y);
42+
evt.setTargetZ(prev.z);
43+
}
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)