-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some useless data. Signed-off-by: 秋雨落 <[email protected]>
- Loading branch information
Showing
13 changed files
with
107 additions
and
125 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
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/cuteneko/catsplus/mixins/bridge/dancing/IMusicianCat.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,11 @@ | ||
package cuteneko.catsplus.mixins.bridge.dancing; | ||
|
||
import net.minecraft.util.math.BlockPos; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface IMusicianCat { | ||
void catsplus$setSoundSource(@Nullable BlockPos pos); | ||
|
||
@Nullable | ||
BlockPos catsplus$getSoundSource(); | ||
} |
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
59 changes: 59 additions & 0 deletions
59
src/main/java/cuteneko/catsplus/mixins/mixin/dancing/CatEntityMixin.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,59 @@ | ||
package cuteneko.catsplus.mixins.mixin.dancing; | ||
|
||
import cuteneko.catsplus.CatsPlusData; | ||
import cuteneko.catsplus.mixins.bridge.dancing.IMusicianCat; | ||
import net.minecraft.entity.EntityData; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.SpawnReason; | ||
import net.minecraft.entity.data.DataTracker; | ||
import net.minecraft.entity.data.TrackedData; | ||
import net.minecraft.entity.data.TrackedDataHandlerRegistry; | ||
import net.minecraft.entity.passive.CatEntity; | ||
import net.minecraft.entity.passive.TameableEntity; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.LocalDifficulty; | ||
import net.minecraft.world.ServerWorldAccess; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(CatEntity.class) | ||
public abstract class CatEntityMixin extends TameableEntity implements IMusicianCat { | ||
@Unique | ||
private static final TrackedData<Boolean> CATSPLUS$SOUND_PLAYING = DataTracker.registerData(CatEntity.class, TrackedDataHandlerRegistry.BOOLEAN); | ||
@Unique | ||
private static final TrackedData<BlockPos> CATSPLUS$SOUND_SOURCE = DataTracker.registerData(CatEntity.class, TrackedDataHandlerRegistry.BLOCK_POS); | ||
|
||
protected CatEntityMixin(EntityType<? extends TameableEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
@Inject(method = "initDataTracker", at = @At("TAIL")) | ||
private void afterInitDataTracker(CallbackInfo ci) { | ||
dataTracker.startTracking(CATSPLUS$SOUND_PLAYING, false); | ||
dataTracker.startTracking(CATSPLUS$SOUND_SOURCE, BlockPos.ORIGIN); | ||
} | ||
|
||
@Override | ||
public @Nullable BlockPos catsplus$getSoundSource() { | ||
if (dataTracker.get(CATSPLUS$SOUND_PLAYING)) { | ||
return dataTracker.get(CATSPLUS$SOUND_SOURCE); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public void catsplus$setSoundSource(@Nullable BlockPos pos) { | ||
dataTracker.set(CATSPLUS$SOUND_PLAYING, pos != null); | ||
|
||
if (pos != null) { | ||
dataTracker.set(CATSPLUS$SOUND_SOURCE, pos); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.