Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
5405fc31
Commit
5405fc31
authored
Aug 06, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Villager trades are now affected by friendship! Be nice! This utilizes the gossip system also.
parent
fc9cee19
Pipeline
#12716
passed with stages
in 1 minute 51 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
6 deletions
+67
-6
CHANGELOG.md
CHANGELOG.md
+1
-0
ChatDataManager.java
src/main/java/com/owlmaddie/chat/ChatDataManager.java
+31
-0
MixinMobEntity.java
src/main/java/com/owlmaddie/mixin/MixinMobEntity.java
+6
-5
MixinVillagerEntity.java
src/main/java/com/owlmaddie/mixin/MixinVillagerEntity.java
+20
-0
VillagerEntityAccessor.java
...main/java/com/owlmaddie/utils/VillagerEntityAccessor.java
+7
-0
creaturechat.mixins.json
src/main/resources/creaturechat.mixins.json
+2
-1
No files found.
CHANGELOG.md
View file @
5405fc31
...
...
@@ -9,6 +9,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Added
-
New LEAD behavior, to guide a player to a random location (and show message when destination is reached)
-
Best friends are now rideable! Right click with an empty hand.
-
Villager trades are now affected by friendship! Be nice!
### Changed
-
Large refactor of how MobEntity avoids targeting players when friendship > 0
...
...
src/main/java/com/owlmaddie/chat/ChatDataManager.java
View file @
5405fc31
...
...
@@ -13,14 +13,17 @@ import com.owlmaddie.message.ParsedMessage;
import
com.owlmaddie.network.ServerPackets
;
import
com.owlmaddie.utils.Randomizer
;
import
com.owlmaddie.utils.ServerEntityFinder
;
import
com.owlmaddie.utils.VillagerEntityAccessor
;
import
net.minecraft.entity.boss.dragon.EnderDragonEntity
;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.entity.passive.VillagerEntity
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.server.MinecraftServer
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.util.Rarity
;
import
net.minecraft.util.WorldSavePath
;
import
net.minecraft.util.math.MathHelper
;
import
net.minecraft.village.VillageGossipType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -336,6 +339,34 @@ public class ChatDataManager {
dragon
.
getFight
().
dragonKilled
(
dragon
);
}
}
// Merchant deals (if friendship changes with a Villager
if
(
entity
instanceof
VillagerEntity
&&
this
.
friendship
!=
new_friendship
)
{
VillagerEntityAccessor
villager
=
(
VillagerEntityAccessor
)
entity
;
switch
(
new_friendship
)
{
case
3
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MAJOR_POSITIVE
,
20
);
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_POSITIVE
,
25
);
break
;
case
2
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_POSITIVE
,
25
);
break
;
case
1
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_POSITIVE
,
10
);
break
;
case
-
1
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_NEGATIVE
,
10
);
break
;
case
-
2
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_NEGATIVE
,
25
);
break
;
case
-
3
:
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MAJOR_NEGATIVE
,
20
);
villager
.
getGossip
().
startGossip
(
player
.
getUuid
(),
VillageGossipType
.
MINOR_NEGATIVE
,
25
);
break
;
}
}
this
.
friendship
=
new_friendship
;
}
}
...
...
src/main/java/com/owlmaddie/mixin/MixinMobEntity.java
View file @
5405fc31
package
com
.
owlmaddie
.
mixin
;
import
com.owlmaddie.chat.ChatDataManager
;
import
com.owlmaddie.commands.ConfigurationHandler
;
import
com.owlmaddie.network.ServerPackets
;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.entity.passive.VillagerEntity
;
import
net.minecraft.entity.player.PlayerEntity
;
import
net.minecraft.item.Item
;
import
net.minecraft.item.ItemStack
;
import
net.minecraft.item.Items
;
import
net.minecraft.registry.Registries
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.util.ActionResult
;
import
net.minecraft.util.Hand
;
import
net.minecraft.util.Identifier
;
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.callback.CallbackInfoReturnable
;
import
java.util.List
;
/**
* The {@code MixinMobEntity} mixin class exposes the goalSelector field from the MobEntity class.
*/
...
...
@@ -31,6 +27,11 @@ public class MixinMobEntity {
ItemStack
itemStack
=
player
.
getStackInHand
(
hand
);
MobEntity
thisEntity
=
(
MobEntity
)
(
Object
)
this
;
// Don't interact with Villagers (avoid issues with trade system)
if
(
thisEntity
instanceof
VillagerEntity
)
{
return
;
}
// Determine if the item is a bucket
// We don't want to interact on buckets
Item
item
=
itemStack
.
getItem
();
...
...
src/main/java/com/owlmaddie/mixin/MixinVillagerEntity.java
0 → 100644
View file @
5405fc31
package
com
.
owlmaddie
.
mixin
;
import
com.owlmaddie.utils.VillagerEntityAccessor
;
import
net.minecraft.entity.passive.VillagerEntity
;
import
net.minecraft.village.VillagerGossips
;
import
org.spongepowered.asm.mixin.Mixin
;
import
org.spongepowered.asm.mixin.Shadow
;
@Mixin
(
VillagerEntity
.
class
)
public
abstract
class
MixinVillagerEntity
implements
VillagerEntityAccessor
{
@Shadow
private
VillagerGossips
gossip
;
@Override
// Access a Villager's gossip system
public
VillagerGossips
getGossip
()
{
return
this
.
gossip
;
}
}
src/main/java/com/owlmaddie/utils/VillagerEntityAccessor.java
0 → 100644
View file @
5405fc31
package
com
.
owlmaddie
.
utils
;
import
net.minecraft.village.VillagerGossips
;
public
interface
VillagerEntityAccessor
{
VillagerGossips
getGossip
();
}
src/main/resources/creaturechat.mixins.json
View file @
5405fc31
...
...
@@ -6,7 +6,8 @@
"MixinMobEntity"
,
"MixinMobEntityAccessor"
,
"MixinLivingEntity"
,
"MixinBucketable"
"MixinBucketable"
,
"MixinVillagerEntity"
],
"injectors"
:
{
"defaultRequire"
:
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment