-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rhysdh540/main
Fix seat height bug on contraptions
- Loading branch information
Showing
16 changed files
with
125 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ build | |
.gradle | ||
run | ||
.DS_Store | ||
src/main/resources/assets/create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/sudolev/interiors/foundation/mixin/AbstractContraptionEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.sudolev.interiors.foundation.mixin; | ||
|
||
import java.util.UUID; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity; | ||
import com.simibubi.create.content.contraptions.Contraption; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Vec3i; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
import com.sudolev.interiors.content.block.seat.BigChairBlock; | ||
|
||
@Mixin(value = AbstractContraptionEntity.class, remap = false) | ||
public abstract class AbstractContraptionEntityMixin { | ||
|
||
@Shadow | ||
protected Contraption contraption; | ||
|
||
@Inject(method = "getPassengerPosition", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) | ||
private void raise(Entity passenger, float partialTicks, CallbackInfoReturnable<Vec3> cir, UUID id, AABB bb, double ySize, BlockPos seat, Vec3 transformedVector) { | ||
Vec3 vec3 = cir.getReturnValue(); | ||
if(contraption.getBlocks().get(seat).state().getBlock() instanceof BigChairBlock) { | ||
cir.setReturnValue(vec3.add(0, 0.34, 0)); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.sudolev.interiors.foundation.mixin; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
import com.simibubi.create.content.contraptions.actors.seat.SeatBlock; | ||
|
||
import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; | ||
|
||
import com.sudolev.interiors.content.block.seat.BigChairBlock; | ||
import com.sudolev.interiors.content.entity.BigSeatEntity; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(value = SeatBlock.class, remap = false) | ||
public abstract class SeatBlockMixin { | ||
|
||
@Inject(method = "isSeatOccupied", at = @At("HEAD"), cancellable = true) | ||
private static void sitDown(Level world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) { | ||
if(!world.getEntitiesOfClass(BigSeatEntity.class, new AABB(pos)).isEmpty()) | ||
cir.setReturnValue(true); | ||
} | ||
|
||
@Redirect(method = "sitDown", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lcom/simibubi/create/content/contraptions/actors/seat/SeatEntity;")) | ||
private static SeatEntity createSeatEntity(Level world, BlockPos pos) { | ||
return world.getBlockState(pos).getBlock() instanceof BigChairBlock | ||
? new BigSeatEntity(world, pos) | ||
: new SeatEntity(world, pos); | ||
} | ||
|
||
@Inject(method = "sitDown", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"), locals = LocalCapture.CAPTURE_FAILHARD) | ||
private static void getY(Level world, BlockPos pos, Entity entity, CallbackInfo ci, SeatEntity seat) { | ||
if(seat instanceof BigSeatEntity) { | ||
seat.setPos(seat.getX(), seat.getY() + .34f, seat.getZ()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.